code stringlengths 20 4.93k | docstring stringlengths 33 1.27k | source stringclasses 3
values |
|---|---|---|
def _ParseShVariables(self, lines):
paths = {}
for line in lines:
for entry in line:
if ('=' in entry):
(target, vals) = (entry.split('=', 1) + [''])[:2]
if vals:
path_vals = vals.split(':')
else:
path_va... | Extract env_var and path values from sh derivative shells.
Iterates over each line, word by word searching for statements that set the
path. These are either variables, or conditions that would allow a variable
to be set later in the line (e.g. export).
Args:
lines: A list of lines, each of which is a list of space s... | codesearchnet |
def _contains_nd(nodes, point):
r
min_vals = np.min(nodes, axis=1)
if not np.all(min_vals <= point):
return False
max_vals = np.max(nodes, axis=1)
if not np.all(point <= max_vals):
return False
return True | r"""Predicate indicating if a point is within a bounding box.
.. note::
There is also a Fortran implementation of this function, which
will be used if it can be built.
Args:
nodes (numpy.ndarray): A set of points.
point (numpy.ndarray): A 1D NumPy array representing a point
in the same dimension as ``nodes``.
Retur... | juraj-google-style |
def _apply_sparse_duplicate_indices(self, grad, var):
summed_values, unique_indices = _deduplicate_indexed_slices(values=grad.values, indices=grad.indices)
gradient_no_duplicate_indices = indexed_slices.IndexedSlices(indices=unique_indices, values=summed_values, dense_shape=grad.dense_shape)
return self._ap... | Add ops to apply sparse gradients to `var`, with repeated sparse indices.
Optimizers which override this method must deal with IndexedSlices objects
such as the following:
IndexedSlicesValue(values=[1, 1], indices=[0, 0], dense_shape=[1])
The correct interpretation is:
IndexedSlicesValue(values=[2], indices=[0], de... | github-repos |
def VerifyStructure(self, parser_mediator, line):
try:
structure = self._DPKG_LOG_LINE.parseString(line)
except pyparsing.ParseException as exception:
logger.debug('Unable to parse Debian dpkg.log file with error: {0!s}'.format(exception))
return False
return (('date_time' in structu... | Verifies if a line from a text file is in the expected format.
Args:
parser_mediator (ParserMediator): parser mediator.
line (str): line from a text file.
Returns:
bool: True if the line is in the expected format, False if not. | codesearchnet |
def get_temp_dir(self) -> str:
if not self._tempdir:
self._tempdir = tempfile.mkdtemp(dir=googletest.GetTempDir())
return self._tempdir | Returns a unique temporary directory for the test to use.
If you call this method multiple times during in a test, it will return the
same folder. However, across different runs the directories will be
different. This will ensure that across different runs tests will not be
able to pollute each others environment.
If ... | github-repos |
def traverse_levelorder(self, leaves=True, internal=True):
q = deque()
q.append(self)
while (len(q) != 0):
n = q.popleft()
if ((leaves and n.is_leaf()) or (internal and (not n.is_leaf()))):
(yield n)
q.extend(n.children) | Perform a levelorder traversal starting at this ``Node`` object
Args:
``leaves`` (``bool``): ``True`` to include leaves, otherwise ``False``
``internal`` (``bool``): ``True`` to include internal nodes, otherwise ``False`` | codesearchnet |
def search(self, terms):
messages = self._connection.get(('search/%s' % urllib.quote_plus(terms)), key='messages')
if messages:
messages = [Message(self, message) for message in messages]
return messages | Search transcripts.
Args:
terms (str): Terms for search
Returns:
array. Messages | codesearchnet |
def get_type(self, index):
if index < 0 or index >= len(self._types):
raise ValueError("Index for getting order parameter type"
" out-of-bounds!")
return self._types[index] | Return type of order parameter at the index provided and
represented by a short string.
Args:
index (int): index of order parameter for which type is
to be returned.
Returns:
str: OP type. | juraj-google-style |
def copy_default_config_to_user_directory(basename, clobber=False, dst_dir='~/.config/scriptabit'):
dst_dir = os.path.expanduser(dst_dir)
dst = os.path.join(dst_dir, basename)
src = resource_filename(Requirement.parse('scriptabit'), os.path.join('scriptabit', basename))
if (not os.path.exists(dst_dir)):... | Copies the default configuration file into the user config directory.
Args:
basename (str): The base filename.
clobber (bool): If True, the default will be written even if a user
config already exists.
dst_dir (str): The destination directory. | codesearchnet |
def turtle_to_texture(turtle_program, turn_amount=DEFAULT_TURN,
initial_angle=DEFAULT_INITIAL_ANGLE, resolution=1):
generator = branching_turtle_generator(
turtle_program, turn_amount, initial_angle, resolution)
return texture_from_generator(generator) | Makes a texture from a turtle program.
Args:
turtle_program (str): a string representing the turtle program; see the
docstring of `branching_turtle_generator` for more details
turn_amount (float): amount to turn in degrees
initial_angle (float): initial orientation of the turtle
resolution (int): if provided, interpol... | juraj-google-style |
def run_step(self, representer):
assert representer, 'ObjectRepresenter instance required to run ObjectRewriterStep.'
rewriter = ObjectRewriter(self.context.get_formatted_iterable, representer)
super().run_step(rewriter) | Do the object in-out rewrite.
Args:
representer: A pypyr.filesystem.ObjectRepresenter instance. | codesearchnet |
def p44(msg):
d = hex2bin(data(msg))
if (d[34] == '0'):
return None
p = bin2int(d[35:46])
return p | Static pressure.
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
int: static pressure in hPa | codesearchnet |
def generate_timing_stats(file_list, var_list):
timing_result = dict()
timing_summary = dict()
for file in file_list:
timing_result[file] = functions.parse_gptl(file, var_list)
for var in var_list:
var_time = []
for f, data in timing_result.items():
try:
... | Parse all of the timing files, and generate some statistics
about the run.
Args:
file_list: A list of timing files to parse
var_list: A list of variables to look for in the timing file
Returns:
A dict containing values that have the form:
[mean, min, max, mean, standard deviation] | juraj-google-style |
def dt_dt(sdat, tstart=None, tend=None):
tseries = sdat.tseries_between(tstart, tend)
time = tseries['t'].values
temp = tseries['Tmean'].values
dtdt = ((temp[1:] - temp[:(- 1)]) / (time[1:] - time[:(- 1)]))
return (dtdt, time[:(- 1)]) | Derivative of temperature.
Compute dT/dt as a function of time using an explicit Euler scheme.
Args:
sdat (:class:`~stagpy.stagyydata.StagyyData`): a StagyyData instance.
tstart (float): time at which the computation should start. Use the
beginning of the time series data if set to None.
tend (float): time at which t... | codesearchnet |
def GetUsedMemory(self):
try:
memory_info = self._process.memory_info()
except psutil.NoSuchProcess:
return None
memory_data = getattr(memory_info, 'data', 0)
memory_shared = getattr(memory_info, 'shared', 0)
return (memory_data + memory_shared) | Retrieves the amount of memory used by the process.
Returns:
int: amount of memory in bytes used by the process or None
if not available. | codesearchnet |
def normal(key, shape, dtype=dtypes.float32):
key = tf_np.asarray(key, dtype=_RNG_KEY_DTYPE)
return tf_np.asarray(stateless_random_ops.stateless_random_normal(shape, seed=_key2seed(key), dtype=dtype)) | Sample standard-normal random values.
Args:
key: the RNG key.
shape: the shape of the result.
dtype: the dtype of the result.
Returns:
Random values in standard-normal distribution. | github-repos |
def plot_feature_correlation_heatmap(df, features, font_size=9, figsize=(15, 15), save_filename=None):
features = features[:]
features += ['target']
mcorr = df[features].corr()
mask = np.zeros_like(mcorr, dtype=np.bool)
mask[np.triu_indices_from(mask)] = True
cmap = sns.diverging_palette... | Plot a correlation heatmap between every feature pair.
Args:
df: Pandas dataframe containing the target column (named 'target').
features: The list of features to include in the correlation plot.
font_size: Font size for heatmap cells and axis labels.
figsize: The size of the plot.
save_filename: (Optional) The path o... | juraj-google-style |
def verify_docker_image_sha(chain, link):
cot = link.cot
task = link.task
errors = []
if isinstance(task['payload'].get('image'), dict):
docker_image_task_id = task['extra']['chainOfTrust']['inputs']['docker-image']
log.debug('Verifying {} {} against docker-image {}'.format(link.name, li... | Verify that built docker shas match the artifact.
Args:
chain (ChainOfTrust): the chain we're operating on.
link (LinkOfTrust): the task link we're checking.
Raises:
CoTError: on failure. | codesearchnet |
def _BuildFindSpecsFromGroupName(self, group_name, environment_variables):
definition = self._artifacts_registry.GetDefinitionByName(group_name)
if (not definition):
return None
return self._BuildFindSpecsFromArtifact(definition, environment_variables) | Builds find specifications from a artifact group name.
Args:
group_name (str): artifact group name.
environment_variables (list[str]): environment variable attributes used to
dynamically populate environment variables in file and registry
artifacts.
Returns:
list[dfwinreg.FindSpec|dfvfs.FindSpec]: find specifications... | codesearchnet |
def _Open(self, path_spec, mode='rb'):
if not path_spec.HasParent():
raise errors.PathSpecError(
'Unsupported path specification without parent.')
file_object = resolver.Resolver.OpenFileObject(
path_spec.parent, resolver_context=self._resolver_context)
try:
file_... | Opens the file system defined by path specification.
Args:
path_spec (PathSpec): path specification.
mode (Optional[str]): file access mode. The default is 'rb' which
represents read-only binary.
Raises:
AccessError: if the access to open the file was denied.
IOError: if the file system could not be opened.
PathSpecE... | juraj-google-style |
def from_json(cls, json_value: Any, *, value_spec: Optional[pg_typing.Dict]=None, allow_partial: bool=False, root_path: Optional[utils.KeyPath]=None, **kwargs) -> 'Dict':
return cls({k: base.from_json(v, root_path=utils.KeyPath(k, root_path), allow_partial=allow_partial, **kwargs) for k, v in json_value.items()}, v... | Class method that load an symbolic Dict from a JSON value.
Args:
json_value: Input JSON value, only JSON dict is acceptable.
value_spec: An optional value spec to apply.
allow_partial: Whether to allow members of the dict to be partial.
root_path: KeyPath of loaded object in its object tree.
**kwargs: Allow passing th... | github-repos |
def get_account_name(config, auth, account):
account_id, advertiser_ids = parse_account(config, auth, account)
is_superuser, profile_id = get_profile_for_api(config, auth, account_id)
response = API_DCM(config, auth, internal=is_superuser).accounts().get(id=account_id, profileId=profile_id).execute()
re... | Return the name of a DCM account given the account ID.
Args:
* auth: (string) Either user or service.
* account: (string) [account:advertiser@profile] token.
Returns:
* Profile ID.
Raises:
* If current credentials do not have a profile for this account. | github-repos |
def build_srpm(specfile, save_dir):
logger.info('Starting rpmbuild to build: {0} SRPM.'.format(specfile))
if save_dir != get_default_save_path():
try:
msg = subprocess.Popen(
['rpmbuild',
'--define', '_sourcedir {0}'.format(save_dir),
'-... | Builds a srpm from given specfile using rpmbuild.
Generated srpm is stored in directory specified by save_dir.
Args:
specfile: path to a specfile
save_dir: path to source and build tree | juraj-google-style |
def pop_parameter(key):
names = key.split('/')
if len(names) > 1:
with parameter_scope(names[0]):
return pop_parameter('/'.join(names[1:]))
global current_scope
param = current_scope.get(key, None)
if param is not None:
del current_scope[key]
return param | Remove and get parameter by key.
Args:
key(str): Key of parameter.
Returns: ~nnabla.Variable
Parameter if key found, otherwise None. | juraj-google-style |
def _collect_paths(element):
output = []
path = vectors.el_to_path_vector(element)
root = path[0]
params = element.params if element.params else None
match = root.find(element.getTagName(), params)
if len(match) == 1:
output.append(
PathCall("find", 0, [element.ge... | Collect all possible path which leads to `element`.
Function returns standard path from root element to this, reverse path,
which uses negative indexes for path, also some pattern matches, like
"this is element, which has neighbour with id 7" and so on.
Args:
element (obj): HTMLElement instance.
Returns:
list: List ... | juraj-google-style |
def _GetDelayImportTimestamps(self, pefile_object):
delay_import_timestamps = []
if (not hasattr(pefile_object, 'DIRECTORY_ENTRY_DELAY_IMPORT')):
return delay_import_timestamps
for importdata in pefile_object.DIRECTORY_ENTRY_DELAY_IMPORT:
dll_name = importdata.dll
try:
dl... | Retrieves timestamps from delay import entries, if available.
Args:
pefile_object (pefile.PE): pefile object.
Returns:
tuple[str, int]: name of the DLL being imported and the second is
the timestamp of the entry. | codesearchnet |
def get_discount_curve(discount_curve_types: List[Union[curve_types_lib.RiskFreeCurve, curve_types_lib.RateIndexCurve]], market: pmd.ProcessedMarketData, mask: List[int]) -> rate_curve.RateCurve:
discount_curves = [market.yield_curve(curve_type) for curve_type in discount_curve_types]
discounts = []
dates =... | Builds a batched discount curve.
Given a list of discount curve an integer mask, creates a discount curve
object to compute discount factors against the list of discount curves.
#### Example
```none
curve_types = [RiskFreeCurve("USD"), RiskFreeCurve("AUD")]
# A mask to price a batch of 7 instruments with the correspo... | github-repos |
def get(self):
with warnings.catch_warnings(record=False):
warnings.simplefilter('ignore')
return np.nanquantile(self._queue, self._q) | Calculates and returns the specified quantile of the current sliding
window.
Returns:
float: The specified quantile of the values in the current sliding window.
Returns NaN if the window is empty. | github-repos |
def get_position_encoding(length, hidden_size, min_timescale=1.0, max_timescale=10000.0):
position = tf.to_float(tf.range(length))
num_timescales = (hidden_size
log_timescale_increment = (math.log((float(max_timescale) / float(min_timescale))) / (tf.to_float(num_timescales) - 1))
inv_timescales = (min_... | Return positional encoding.
Calculates the position encoding as a mix of sine and cosine functions with
geometrically increasing wavelengths.
Defined and formulized in Attention is All You Need, section 3.5.
Args:
length: Sequence length.
hidden_size: Size of the
min_timescale: Minimum scale that will be applied at e... | codesearchnet |
def install_hook(self, hook_name, hook_content):
hook_path = os.path.join(self.path, '.git/hooks', hook_name)
with open(hook_path, 'w') as f:
f.write(hook_content)
os.chmod(hook_path, ((stat.S_IEXEC | stat.S_IREAD) | stat.S_IWRITE)) | Install the repository hook for this repo.
Args:
hook_name (str)
hook_content (str) | codesearchnet |
def get_variable_name_from_bird(bird_conf):
bird_variable_pattern = re.compile(
r, re.VERBOSE
)
with open(bird_conf, 'r') as content:
for line in content.readlines():
variable_match = bird_variable_pattern.search(line)
if variable_match:
return v... | Return the variable name set in Bird configuration.
The variable name in Bird configuration is set with the keyword 'define',
here is an example:
define ACAST_PS_ADVERTISE =
and we exract the string between the word 'define' and the equals sign.
Arguments:
bird_conf (str): The absolute file name path of Bird config... | juraj-google-style |
def add_forwarding_rules(self, forwarding_rules):
rules_dict = [rule.__dict__ for rule in forwarding_rules]
return self.get_data(('load_balancers/%s/forwarding_rules/' % self.id), type=POST, params={'forwarding_rules': rules_dict}) | Adds new forwarding rules to a LoadBalancer.
Args:
forwarding_rules (obj:`list`): A list of `ForwrdingRules` objects | codesearchnet |
class XLMPoolerAnswerClass(nn.Module):
def __init__(self, config: XLMConfig):
super().__init__()
self.dense_0 = nn.Linear(config.hidden_size * 2, config.hidden_size)
self.activation = nn.Tanh()
self.dense_1 = nn.Linear(config.hidden_size, 1, bias=False)
def forward(self, hidden... | Compute SQuAD 2.0 answer class from classification and start tokens hidden states.
Args:
config ([`XLMConfig`]):
The config used by the model, will be used to grab the `hidden_size` of the model. | github-repos |
def _inplace_helper(x, i, v, op):
x = ops.convert_to_tensor(x)
v = ops.convert_to_tensor(v, x.dtype)
if i is None:
return array_ops.reshape(op(array_ops.reshape(x, [1, -1]), [0], array_ops.reshape(v, [1, -1])), array_ops.shape(x))
i = math_ops.cast(i, dtypes.int32)
if i.get_shape().ndims == ... | Applies an inplace op on (x, i, v).
op is one of gen_array_ops.alias_inplace_update,
gen_array_ops.alias_inplace_add, or gen_array_ops.alias_inplace_sub.
If i is None, x and v must be the same shape. Computes
x op v;
If i is a scalar, x has a rank 1 higher than v's. Computes
x[i, :] op v;
Otherwise, x and v must have... | github-repos |
def signUserCsr(self, xcsr, signas, outp=None):
pkey = xcsr.get_pubkey()
name = xcsr.get_subject().CN
return self.genUserCert(name, csr=pkey, signas=signas, outp=outp) | Signs a user CSR with a CA keypair.
Args:
cert (OpenSSL.crypto.X509Req): The certificate signing request.
signas (str): The CA keypair name to sign the CSR with.
outp (synapse.lib.output.Output): The output buffer.
Examples:
cdir.signUserCsr(mycsr, 'myca')
Returns:
((OpenSSL.crypto.PKey, OpenSSL.crypto.X509)): Tuple... | codesearchnet |
def attach(self, engine, log_handler, event_name):
if event_name not in State.event_to_attr:
raise RuntimeError("Unknown event name '{}'".format(event_name))
engine.add_event_handler(event_name, log_handler, self, event_name) | Attach the logger to the engine and execute `log_handler` function at `event_name` events.
Args:
engine (Engine): engine object.
log_handler (callable): a logging handler to execute
event_name: event to attach the logging handler to. Valid events are from :class:`~ignite.engine.Events`
or any `event_name` added by :me... | juraj-google-style |
def save_screenshot(self, filename, quietly=False):
imgData = self.take_screenshot()
try:
with open(filename, 'wb') as f:
f.write(b64decode(imgData.encode('ascii')))
except IOError as err:
if (not quietly):
raise err | Save the screenshot to local.
Support:
Android iOS Web(WebView)
Args:
filename(str): The path to save the image.
quietly(bool): If True, omit the IOError when
failed to save the image.
Returns:
WebElement Object.
Raises:
WebDriverException.
IOError. | codesearchnet |
def _ParsePerformanceOptions(self, options):
self._buffer_size = getattr(options, 'buffer_size', 0)
if self._buffer_size:
try:
if (self._buffer_size[(- 1)].lower() == 'm'):
self._buffer_size = int(self._buffer_size[:(- 1)], 10)
self._buffer_size *= self._BYTES... | Parses the performance options.
Args:
options (argparse.Namespace): command line arguments.
Raises:
BadConfigOption: if the options are invalid. | codesearchnet |
def _ConsumeInteger(tokenizer, is_signed=False, is_long=False):
try:
result = ParseInteger(tokenizer.token, is_signed=is_signed, is_long=is_long)
except ValueError as e:
raise tokenizer.ParseError(str(e))
tokenizer.NextToken()
return result | Consumes an integer number from tokenizer.
Args:
tokenizer: A tokenizer used to parse the number.
is_signed: True if a signed integer must be parsed.
is_long: True if a long integer must be parsed.
Returns:
The integer parsed.
Raises:
ParseError: If an integer with given characteristics couldn't be consumed. | juraj-google-style |
def get_sample_dataset(dataset_properties):
kwargs = dataset_properties.copy()
data_type = kwargs.pop('type')
if data_type == 'multiclass':
try:
X, y = datasets.make_classification(random_state=8, **kwargs)
splits = model_selection.StratifiedKFold(n_splits=2, random_stat... | Returns sample dataset
Args:
dataset_properties (dict): Dictionary corresponding to the properties of the dataset
used to verify the estimator and metric generators.
Returns:
X (array-like): Features array
y (array-like): Labels array
splits (iterator): This is an iterator that returns train test splits for
cross-v... | juraj-google-style |
def getEntity(self, name):
return lock_and_call(
lambda: Entity(self._impl.getEntity(name)),
self._lock
) | Get entity corresponding to the specified name (looks for it in all
types of entities).
Args:
name: Name of the entity.
Raises:
TypeError: if the specified entity does not exist.
Returns:
The AMPL entity with the specified name. | juraj-google-style |
def user_picklist(i_info, command):
valid_entry = False
awsc.get_all_aminames(i_info)
list_instances(i_info, "", True)
msg_txt = ("Enter {0}
" [{2}0 aborts{1}]: ".format(C_WARN, C_NORM, C_TI,
command, len(i_info)))
while not valid_entry... | Display list of instances matching args and ask user to select target.
Instance list displayed and user asked to enter the number corresponding
to the desired target instance, or '0' to abort.
Args:
i_info (dict): information on instances and details.
command (str): command specified on the command line.
Returns:
tar... | juraj-google-style |
def convert_phase(component, subcomponent=SubComponent.UNSPECIFIED):
if component not in Component:
raise ValueError('Given component name not found')
if subcomponent not in SubComponent:
raise ValueError('Given subcomponent name not found')
if subcomponent != SubComponent.UNSPECIFIED and su... | The decorator to identify converter component and subcomponent.
Args:
component: Converter component name.
subcomponent: Converter subcomponent name.
Returns:
Forward the result from the wrapped function.
Raises:
ValueError: if component and subcomponent name is not valid. | github-repos |
def dropout_no_scaling(x, keep_prob):
if (keep_prob == 1.0):
return x
mask = tf.less(tf.random_uniform(tf.shape(x)), keep_prob)
return (x * cast_like(mask, x)) | Like tf.nn.dropout, but does not scale up. Works on integers also.
Args:
x: a Tensor
keep_prob: a floating point number
Returns:
Tensor of the same shape as x. | codesearchnet |
def stopService(self):
self._service.factory.stopTrying()
(yield self._service.factory.stopFactory())
(yield service.MultiService.stopService(self)) | Gracefully stop the service.
Returns:
defer.Deferred: a Deferred which is triggered when the service has
finished shutting down. | codesearchnet |
def patch_traces(self, project_id, traces):
traces_pb = _traces_mapping_to_pb(traces)
self._gapic_api.patch_traces(project_id, traces_pb) | Sends new traces to Stackdriver Trace or updates existing traces.
Args:
project_id (Optional[str]): ID of the Cloud project where the trace
data is stored.
traces (dict): Required. The traces to be patched in the API call. | juraj-google-style |
def dependency_to_rpm(dep, runtime):
logger.debug('Dependencies provided: {0} runtime: {1}.'.format(
dep, runtime))
converted = []
if not len(dep.specs):
converted.append(['Requires', dep.project_name])
else:
for ver_spec in dep.specs:
if ver_spec[0] == '!=':
... | Converts a dependency got by pkg_resources.Requirement.parse()
to RPM format.
Args:
dep - a dependency retrieved by pkg_resources.Requirement.parse()
runtime - whether the returned dependency should be runtime (True)
or build time (False)
Returns:
List of semi-SPECFILE dependencies (package names are not properly
conve... | juraj-google-style |
def get_arg_value(node, arg_name, arg_pos=None):
if arg_name is not None:
for kw in node.keywords:
if kw.arg == arg_name:
return (True, kw.value)
if arg_pos is not None:
idx = 0
for arg in node.args:
if sys.version_info[:2] >= (3, 5) and isinstance... | Get the value of an argument from a ast.Call node.
This function goes through the positional and keyword arguments to check
whether a given argument was used, and if so, returns its value (the node
representing its value).
This cannot introspect *args or **args, but it safely handles *args in
Python3.5+.
Args:
node:... | github-repos |
def speed_difference(points):
data = [0]
for before, after in pairwise(points):
data.append(before.vel - after.vel)
return data | Computes the speed difference between each adjacent point
Args:
points (:obj:`Point`)
Returns:
:obj:`list` of int: Indexes of changepoints | juraj-google-style |
def get_meas_los(self, user_lo_config):
try:
_m_los = self.default_meas_los.copy()
except KeyError:
raise PulseError('Default measurement frequencies not exist.')
for channel, lo_freq in user_lo_config.meas_lo_dict().items():
_m_los[channel.index] = ... | Embed default meas LO frequencies from backend and format them to list object.
If configured lo frequency is the same as default, this method returns `None`.
Args:
user_lo_config (LoConfig): A dictionary of LOs to format.
Returns:
list: A list of meas LOs.
Raises:
PulseError: when LO frequencies are missing. | juraj-google-style |
def _make_3d(field, twod):
shp = list(field.shape)
if twod and 'X' in twod:
shp.insert(1, 1)
elif twod:
shp.insert(0, 1)
return field.reshape(shp) | Add a dimension to field if necessary.
Args:
field (numpy.array): the field that need to be 3d.
twod (str): 'XZ', 'YZ' or None depending on what is relevant.
Returns:
numpy.array: reshaped field. | juraj-google-style |
def generate_reciprocal_vectors_squared(a1, a2, a3, encut):
for vec in genrecip(a1, a2, a3, encut):
yield np.dot(vec, vec) | Generate reciprocal vector magnitudes within the cutoff along the specied
lattice vectors.
Args:
a1: Lattice vector a (in Bohrs)
a2: Lattice vector b (in Bohrs)
a3: Lattice vector c (in Bohrs)
encut: Reciprocal vector energy cutoff
Returns:
[[g1^2], [g2^2], ...] Square of reciprocal vectors (1/Bohr)^2
determined by a1... | juraj-google-style |
def load_from_files(files, globs: Optional[Dict[str, Any]]=None, set_up: Optional[Callable[[Any], None]]=None, tear_down: Optional[Callable[[Any], None]]=None) -> doctest.DocFileSuite:
if globs is None:
globs = {}
files = [os.fspath(f) for f in files]
globs['_print_if_not_none'] = _print_if_not_none... | Creates a doctest suite from the files list.
Args:
files: A list of file paths to test.
globs: The global namespace the tests are run in.
set_up: Run before each test, receives the test as argument.
tear_down: Run after each test, receives the test as argument.
Returns:
A DocFileSuite containing the tests. | github-repos |
def load_feather(protein_feather, length_filter_pid=None, copynum_scale=False, copynum_df=None):
protein_df = pd.read_feather(protein_feather).set_index('index')
from ssbio.protein.sequence.properties.residues import _aa_property_dict_one, EXTENDED_AA_PROPERTY_DICT_ONE
aggregators = {'aa_count_bulk': {'resi... | Load a feather of amino acid counts for a protein.
Args:
protein_feather (str): path to feather file
copynum_scale (bool): if counts should be multiplied by protein copy number
copynum_df (DataFrame): DataFrame of copy numbers
Returns:
DataFrame: of counts with some aggregated together | codesearchnet |
def getText(page, output = "text"):
CheckParent(page)
dl = page.getDisplayList()
formats = ("text", "html", "json", "xml", "xhtml", "dict", "rawdict")
images = (0, 1, 1, 0, 1, 1, 1)
try:
f = formats.index(output.lower())
except:
f = 0
flags = TEXT_PRESERV... | Extract a document page's text.
Args:
output: (str) text, html, dict, json, rawdict, xhtml or xml.
Returns:
the output of TextPage methods extractText, extractHTML, extractDICT, extractJSON, extractRAWDICT, extractXHTML or etractXML respectively. Default and misspelling choice is "text". | juraj-google-style |
def getattr(self, c, attr, default=None, match_only=None):
matching_decor = self.get_decor(c, match_only=match_only)
try:
return getattr(matching_decor, attr)
except AttributeError:
return default | Get the attribute of a component.
Args:
c (component): The component to look up.
attr (str): The attribute to get.
default (str): What to return in the event of no match.
match_only (list of str): The component attributes to include in the
comparison. Default: All of them.
Returns:
obj. The specified attribute of the... | codesearchnet |
def FromString(val):
if isinstance(val, bytes):
val = val.decode('utf-8')
try:
return ContractParameterType[val]
except Exception as e:
pass
try:
if isinstance(val, (bytearray, bytes)):
... | Create a ContractParameterType object from a str
Args:
val (str): the value to be converted to a ContractParameterType.
val can be hex encoded (b'07'), int (7), string int ("7"), or string literal ("String")
Returns:
ContractParameterType | juraj-google-style |
def DeregisterHelper(cls, helper_class):
helper_name = helper_class.NAME.lower()
if (helper_name not in cls._helper_classes):
raise KeyError('Helper class not set for name: {0:s}.'.format(helper_class.NAME))
del cls._helper_classes[helper_name] | Deregisters a helper class.
The helper classes are identified based on their lower case name.
Args:
helper_class (type): class object of the argument helper.
Raises:
KeyError: if helper class is not set for the corresponding name. | codesearchnet |
def destroy_unit(self, unit):
if isinstance(unit, Unit):
unit = unit.name
else:
unit = str(unit)
self._single_request('Units.Delete', unitName=unit)
return True | Delete a unit from the cluster
Args:
unit (str, Unit): The Unit, or name of the unit to delete
Returns:
True: The unit was deleted
Raises:
fleet.v1.errors.APIError: Fleet returned a response code >= 400 | codesearchnet |
def scatter(self, indices, value, name=None):
return self._implementation.scatter(indices, value, name=name) | Scatter the values of a `Tensor` in specific indices of a `TensorArray`.
Args:
indices: A `1-D` `Tensor` taking values in `[0, max_value)`. If the
`TensorArray` is not dynamic, `max_value=size()`.
value: (N+1)-D. Tensor of type `dtype`. The Tensor to unpack.
name: A name for the operation (optional).
Returns:
A ne... | github-repos |
def circuit_to_dag(circuit):
dagcircuit = DAGCircuit()
dagcircuit.name = circuit.name
for register in circuit.qregs:
dagcircuit.add_qreg(register)
for register in circuit.cregs:
dagcircuit.add_creg(register)
for (instruction, qargs, cargs) in circuit.data:
if (instruction.con... | Build a ``DAGCircuit`` object from a ``QuantumCircuit``.
Args:
circuit (QuantumCircuit): the input circuit.
Return:
DAGCircuit: the DAG representing the input circuit. | codesearchnet |
def to_dict(self):
return {'node': [v.to_dict() for v in self.vertices], 'edge': [e.to_dict() for e in self.edges]} | Returns a simplified dictionary representing the Graph.
Returns:
A dictionary that can easily be serialized to JSON. | codesearchnet |
def _prepare_4d_attention_mask(attention_mask: Optional[torch.Tensor], sequence_length: int, dtype: torch.dtype, device: torch.device, is_causal: bool=True) -> Optional[torch.Tensor]:
min_value = torch.finfo(dtype).min if dtype.is_floating_point else torch.iinfo(dtype).min
if attention_mask is not None:
... | Creates 4D attention mask and combines causal and padding masks if needed.
Args:
attention_mask: Optional tensor of shape (batch_size, seq_length) containing padding mask
sequence_length: Length of the sequence
dtype: Data type of the mask
device: Device of the mask
is_causal: Whether to apply causal masking
Returns:... | github-repos |
def set_weights(distribution_strategy, dist_model, weights):
assign_ops = []
for layer in dist_model.layers:
num_param = len(layer.weights)
layer_weights = weights[:num_param]
for sw, w in zip(layer.weights, layer_weights):
if ops.executing_eagerly_outside_functions():
... | Sets the weights of the replicated models.
The weights of the replicated models are set to the weights of the original
model. The weights of the replicated model are Mirrored variables and hence
we need to use the `update` call within a DistributionStrategy scope.
Args:
distribution_strategy: DistributionStrategy use... | github-repos |
def _upload_artifacts_to_path(self, mirror=False):
if not os.listdir(self.artifact_path) or not self.artifact_path:
raise S3ArtifactNotFound
uploaded = False
if self.s3props.get("content_metadata"):
LOG.info("Uploading in multiple parts to set metadata")
... | Recursively upload directory contents to S3.
Args:
mirror (bool): If true, uses a flat directory structure instead of nesting under a version. | juraj-google-style |
def call(self, input_ids=None, position_ids=None, token_type_ids=None, inputs_embeds=None, past_key_values_length=0, training=False):
assert not (input_ids is None and inputs_embeds is None)
if input_ids is not None:
check_embeddings_within_bounds(input_ids, self.config.vocab_size)
inputs_embeds... | Applies embedding based on inputs tensor.
Returns:
final_embeddings (`tf.Tensor`): output embedding tensor. | github-repos |
def _count_condition(values, weights=None, metrics_collections=None, updates_collections=None):
check_ops.assert_type(values, dtypes.bool)
count = metric_variable([], dtypes.float32, name='count')
values = math_ops.cast(values, dtypes.float32)
if weights is not None:
with ops.control_dependencie... | Sums the weights of cases where the given values are True.
If `weights` is `None`, weights default to 1. Use weights of 0 to mask values.
Args:
values: A `bool` `Tensor` of arbitrary size.
weights: Optional `Tensor` whose rank is either 0, or the same rank as
`values`, and must be broadcastable to `values` (i.e., all... | github-repos |
def add_byte_counter(self, reader):
def update_bytes_read(record_size, is_record_size=False, **kwargs):
if is_record_size:
self.read_counter.add_bytes_read(record_size)
if isinstance(reader, observable.ObservableMixin):
reader.register_observer(update_bytes_read) | Adds byte counter observer to a side input reader.
Args:
reader: A reader that should inherit from ObservableMixin to have
bytes tracked. | github-repos |
def read(self, size=None):
if not self._is_open:
raise IOError('Not opened.')
if self._current_offset < 0:
raise IOError(
'Invalid current offset: {0:d} value less than zero.'.format(
self._current_offset))
if self._uncompressed_stream_size is None:
self._unc... | Reads a byte string from the file-like object at the current offset.
The function will read a byte string of the specified size or
all of the remaining data if no size was specified.
Args:
size (Optional[int]): number of bytes to read, where None is all
remaining data.
Returns:
bytes: data read.
Raises:
IOError: if... | juraj-google-style |
def apply_to_structure(self, structure):
def_struct = structure.copy()
old_latt = def_struct.lattice.matrix
new_latt = np.transpose(np.dot(self, np.transpose(old_latt)))
def_struct.lattice = Lattice(new_latt)
return def_struct | Apply the deformation gradient to a structure.
Args:
structure (Structure object): the structure object to
be modified by the deformation | juraj-google-style |
def _call_api(self, verb, url, **request_kwargs):
api = 'https:
auth_headers = {'Authorization': 'token {}'.format(self.api_token)}
headers = {**auth_headers, **request_kwargs.pop('headers', {})}
return getattr(requests, verb)(api, headers=headers, **request_kwargs) | Perform a github API call
Args:
verb (str): Can be "post", "put", or "get"
url (str): The base URL with a leading slash for Github API (v3)
auth (str or HTTPBasicAuth): A Github API token or a HTTPBasicAuth object | codesearchnet |
def prepare_question_encoder(inputs, hparams):
encoder_input = inputs
encoder_padding = common_attention.embedding_to_padding(encoder_input)
ignore_padding = common_attention.attention_bias_ignore_padding(
encoder_padding)
encoder_self_attention_bias = ignore_padding
if hparams.pos == "timing":
... | Prepare question encoder.
Args:
inputs: a Tensor.
hparams: run hyperparameters
Returns:
encoder_input: a Tensor, bottom of encoder stack
encoder_self_attention_bias: a bias tensor for use in encoder self-attention | juraj-google-style |
def ExtractEvents(
self, parser_mediator, registry_key, codepage='cp1252', **kwargs):
self._ParseMRUListExKey(parser_mediator, registry_key, codepage=codepage)
if registry_key.name == 'RecentDocs':
for subkey in registry_key.GetSubkeys():
self._ParseMRUListExKey(parser_me... | Extracts events from a Windows Registry key.
Args:
parser_mediator (ParserMediator): mediates interactions between parsers
and other components, such as storage and dfvfs.
registry_key (dfwinreg.WinRegistryKey): Windows Registry key.
codepage (Optional[str]): extended ASCII string codepage. | juraj-google-style |
def easeOutBounce(n):
_checkRange(n)
if (n < (1 / 2.75)):
return ((7.5625 * n) * n)
elif (n < (2 / 2.75)):
n -= (1.5 / 2.75)
return (((7.5625 * n) * n) + 0.75)
elif (n < (2.5 / 2.75)):
n -= (2.25 / 2.75)
return (((7.5625 * n) * n) + 0.9375)
else:
n -= ... | A bouncing tween function that hits the destination and then bounces to rest.
Args:
n (float): The time progress, starting at 0.0 and ending at 1.0.
Returns:
(float) The line progress, starting at 0.0 and ending at 1.0. Suitable for passing to getPointOnLine(). | codesearchnet |
def _load_certificate(location):
if location.startswith('https:
_log.info('Downloading x509 certificate from %s', location)
with requests.Session() as session:
session.mount('https:
response = session.get(location, timeout=30)
response.raise_for_status()
... | Load a certificate from the given location.
Args:
location (str): The location to load. This can either be an HTTPS URL or an absolute file
path. This is intended to be used with PEM-encoded certificates and therefore assumes
ASCII encoding.
Returns:
str: The PEM-encoded certificate as a unicode string.
Raises:
requ... | codesearchnet |
def _schedule_shards(cls, spec, readers, queue_name, base_path, mr_state):
shard_states = []
for (shard_number, input_reader) in enumerate(readers):
shard_state = model.ShardState.create_new(spec.mapreduce_id, shard_number)
shard_state.shard_description = str(input_reader)
shard_states.a... | Prepares shard states and schedules their execution.
Even though this method does not schedule shard task and save shard state
transactionally, it's safe for taskqueue to retry this logic because
the initial shard_state for each shard is the same from any retry.
This is an important yet reasonable assumption on model.... | codesearchnet |
def compare_jsone_task_definition(parent_link, rebuilt_definitions):
diffs = []
for compare_definition in rebuilt_definitions['tasks']:
if ('taskId' in compare_definition):
del compare_definition['taskId']
compare_definition = remove_empty_keys(compare_definition)
runtime_def... | Compare the json-e rebuilt task definition vs the runtime definition.
Args:
parent_link (LinkOfTrust): the parent link to test.
rebuilt_definitions (dict): the rebuilt task definitions.
Raises:
CoTError: on failure. | codesearchnet |
def multisorted(items, *keys):
if len(keys) == 0:
keys = [asc()]
for key in reversed(keys):
items = sorted(items, key=key.func, reverse=key.reverse)
return items | Sort by multiple attributes.
Args:
items: An iterable series to be sorted.
*keys: Key objects which extract key values from the items.
The first key will be the most significant, and the
last key the least significant. If no key functions
are provided, the items will be sorted in ascending
natural order.
Returns:
A li... | juraj-google-style |
def process(self, elem: t.Any):
pass | Process is the operation that will be rate limited.
Results will be yielded each time time the process method is called.
Args:
elem: The individual element to process.
Returns:
Output can be anything, output will be the output of the RateLimit
PTransform. | github-repos |
def convert_videos_to_summaries(input_videos, output_videos, target_videos, tag, decode_hparams, display_ground_truth=False):
fps = decode_hparams.frames_per_second
border_percent = decode_hparams.border_percent
max_outputs = decode_hparams.max_display_outputs
target_steps = target_videos.shape[1]
a... | Converts input, output and target videos into video summaries.
Args:
input_videos: 5-D NumPy array, (NTHWC) conditioning frames.
output_videos: 5-D NumPy array, (NTHWC) model predictions.
target_videos: 5-D NumPy array, (NTHWC) target frames.
tag: tf summary tag.
decode_hparams: HParams.
display_ground_truth: Whether ... | codesearchnet |
def find(self, username):
filter = ['(uid={})'.format(username)]
results = self.client.search(filter)
if (len(results) < 1):
raise ldap_tools.exceptions.NoUserFound('User ({}) not found'.format(username))
return
elif (len(results) > 1):
raise ldap_tools.exceptions.TooManyResults(... | Find user with given username.
Args:
username Username of the user to search for
Raises:
ldap_tools.exceptions.NoUserFound: No users returned by LDAP
ldap_tools.exceptions.TooManyResults:
Multiple users returned by LDAP | codesearchnet |
def _prepare_summary_table(rows):
if (not rows):
return []
key_field = 'job-name'
if (key_field not in rows[0]):
key_field = 'job-id'
grouped = collections.defaultdict((lambda : collections.defaultdict((lambda : []))))
for row in rows:
grouped[row.get(key_field, '')][row.get(... | Create a new table that is a summary of the input rows.
All with the same (job-name or job-id, status) go together.
Args:
rows: the input rows, a list of dictionaries.
Returns:
A new row set of summary information. | codesearchnet |
def on_test_begin(self, logs=None):
logs = self._process_logs(logs)
for callback in self.callbacks:
callback.on_test_begin(logs) | Calls the `on_test_begin` methods of its callbacks.
Args:
logs: Dict. Currently no data is passed to this argument for this method
but that may change in the future. | github-repos |
class BaseModelOutputWithCLSToken(ModelOutput):
last_hidden_state: Optional[torch.FloatTensor] = None
cls_token_value: Optional[torch.FloatTensor] = None
hidden_states: Optional[Tuple[torch.FloatTensor, ...]] = None | Base class for model's outputs, with potential hidden states and attentions.
Args:
last_hidden_state (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`):
Sequence of hidden-states at the output of the last layer of the model.
cls_token_value (`torch.FloatTensor` of shape `(batch_size, 1, hidden... | github-repos |
def __init__(self, session_root, watch_fn=None, thread_name_filter=None):
self._session_root = session_root
self._watch_fn = watch_fn
self._thread_name_filter = thread_name_filter
self._session_wrapper = None | Create a local debugger command-line interface (CLI) hook.
Args:
session_root: See doc of
`dumping_wrapper.DumpingDebugWrapperSession.__init__`.
watch_fn: See doc of
`dumping_wrapper.DumpingDebugWrapperSession.__init__`.
thread_name_filter: Regular-expression white list for threads on which the
wrapper session will be... | github-repos |
def rename(self, name):
return self.client.api.rename(self.id, name) | Rename this container. Similar to the ``docker rename`` command.
Args:
name (str): New name for the container
Raises:
:py:class:`docker.errors.APIError`
If the server returns an error. | juraj-google-style |
async def _get_person_json(self, id_, url_params=None):
url = self.url_builder(
'person/{person_id}',
dict(person_id=id_),
url_params=url_params or OrderedDict(),
)
data = await self.get_data(url)
return data | Retrieve raw person JSON by ID.
Arguments:
id_ (:py:class:`int`): The person's TMDb ID.
url_params (:py:class:`dict`): Any additional URL parameters.
Returns:
:py:class:`dict`: The JSON data. | juraj-google-style |
def get_evaluation_parameter(self, parameter_name, default_value=None):
if (('evaluation_parameters' in self._expectations_config) and (parameter_name in self._expectations_config['evaluation_parameters'])):
return self._expectations_config['evaluation_parameters'][parameter_name]
else:
return d... | Get an evaluation parameter value that has been stored in meta.
Args:
parameter_name (string): The name of the parameter to store.
default_value (any): The default value to be returned if the parameter is not found.
Returns:
The current value of the evaluation parameter. | codesearchnet |
def _send_data(self, data, start_offset, file_len):
headers = {}
end_offset = ((start_offset + len(data)) - 1)
if data:
headers['content-range'] = ('bytes %d-%d/%s' % (start_offset, end_offset, file_len))
else:
headers['content-range'] = ('bytes */%s' % file_len)
(status, response_he... | Send the block to the storage service.
This is a utility method that does not modify self.
Args:
data: data to send in str.
start_offset: start offset of the data in relation to the file.
file_len: an int if this is the last data to append to the file.
Otherwise '*'. | codesearchnet |
def all_v2_summary_ops():
if context.executing_eagerly():
return None
return ops.get_collection(ops.GraphKeys._SUMMARY_COLLECTION) | Returns all V2-style summary ops defined in the current default graph.
This includes ops from TF 2.0 tf.summary and TF 1.x tf.contrib.summary (except
for `tf.contrib.summary.graph` and `tf.contrib.summary.import_event`), but
does *not* include TF 1.x tf.summary ops.
Returns:
List of summary ops, or None if called und... | github-repos |
def build_inception_graph(self):
image_str_tensor = tf.placeholder(tf.string, shape=[None])
image = tf.map_fn(_util.decode_and_resize, image_str_tensor, back_prop=False, dtype=tf.uint8)
image = tf.image.convert_image_dtype(image, dtype=tf.float32)
image = tf.subtract(image, 0.5)
image = tf.multiply(... | Builds an inception graph and add the necessary input & output tensors.
To use other Inception models modify this file. Also preprocessing must be
modified accordingly.
See tensorflow/contrib/slim/python/slim/nets/inception_v3.py for
details about InceptionV3.
Returns:
input_jpeg: A placeholder for jpeg string batch... | codesearchnet |
def set_dataset_date(self, dataset_date, dataset_end_date=None, date_format=None):
parsed_date = self._parse_date(dataset_date, date_format)
if dataset_end_date is None:
self.set_dataset_date_from_datetime(parsed_date)
else:
parsed_end_date = self._parse... | Set dataset date from string using specified format. If no format is supplied, the function will guess.
For unambiguous formats, this should be fine.
Args:
dataset_date (str): Dataset date string
dataset_end_date (Optional[str]): Dataset end date string
date_format (Optional[str]): Date format. If None is given, will ... | juraj-google-style |
def add(self, payload=None):
try:
db = self._client[self.database]
col = db[WORKFLOW_DATA_COLLECTION_NAME]
return str(col.insert_one({
DataStoreDocumentSection.Meta:
payload if isinstance(payload, dict) else {},
Dat... | Adds a new document to the data store and returns its id.
Args:
payload (dict): Dictionary of initial data that should be stored
in the new document in the meta section.
Raises:
DataStoreNotConnected: If the data store is not connected to the server.
Returns:
str: The id of the newly created document. | juraj-google-style |
def _countIdentities(self, nodes):
return len([x for x in nodes if x.op == 'Identity']) | Count the number of "Identity" op types in the list of proto nodes.
Args:
nodes: NodeDefs of the graph.
Returns:
The number of nodes with op type "Identity" found. | github-repos |
def add_comment(self, app_id, record_id, field_id, message):
self._swimlane.request('post', 'app/{0}/record/{1}/{2}/comment'.format(app_id, record_id, field_id), json={'message': message, 'createdDate': pendulum.now().to_rfc3339_string()}) | Directly add a comment to a record without retrieving the app or record first
Warnings:
Does not perform any app, record, or field ID validation
Args:
app_id (str): Full App ID string
record_id (str): Full parent Record ID string
field_id (str): Full field ID to target reference field on parent Record string
message ... | codesearchnet |
def load_user_config(vcs):
config_path = os.path.join(vcs.path, 'eci.yaml')
if (not os.path.exists(config_path)):
raise ConfigNotFoundError
with open(config_path, 'r') as f:
try:
config = yaml.safe_load(f)
except yaml.YAMLError:
raise ConfigFormatError
if ... | Load the user config
Args:
vcs (easyci.vcs.base.Vcs) - the vcs object for the current project
Returns:
dict - the config
Raises:
ConfigFormatError
ConfigNotFoundError | codesearchnet |
def should_collapse(self, value: Any, name: Optional[str], root_path: KeyPath, parent: Any, collapse_level: Optional[int]=1, uncollapse: Union[KeyPathSet, base.NodeFilter]=None) -> bool:
if collapse_level is None or collapse_level > 0:
return False
if callable(uncollapse):
return not uncollapse(... | Returns True if the object should be collapsed.
Args:
value: The value to render.
name: The referred field name of the value.
root_path: The root path of the value.
parent: The parent of the value.
collapse_level: The level of collapsing. If 0, the object will be
collapsed (without showing its sub-nodes). If 1, the im... | github-repos |
def _peer_get_bfd(self, tx, rx, multiplier):
tx = self._callback(tx, handler='get_config')
rx = self._callback(rx, handler='get_config')
multiplier = self._callback(multiplier, handler='get_config')
tx = pynos.utilities.return_xml(str(tx))
rx = pynos.utilities.return_xml(str(rx))
multiplier = py... | Get and merge the `bfd` config from global BGP.
You should not use this method.
You probably want `BGP.bfd`.
Args:
tx: XML document with the XML to get the transmit interval.
rx: XML document with the XML to get the receive interval.
multiplier: XML document with the XML to get the interval
multiplier.
Returns:
Merg... | codesearchnet |
def adjoint(self, name: str='adjoint') -> 'LinearOperator':
if self.is_self_adjoint is True:
return self
with self._name_scope(name):
return self._linop_adjoint() | Returns the adjoint of the current `LinearOperator`.
Given `A` representing this `LinearOperator`, return `A*`.
Note that calling `self.adjoint()` and `self.H` are equivalent.
Args:
name: A name for this `Op`.
Returns:
`LinearOperator` which represents the adjoint of this `LinearOperator`. | github-repos |
def slice_inputs(indices_dataset, inputs):
inputs = array_slicing.convert_to_sliceable(self._inputs, target_backend='tensorflow')
inputs = tree.lists_to_tuples(inputs)
dataset = tf.data.Dataset.zip((indices_dataset, tf.data.Dataset.from_tensors(inputs).repeat()))
def grab_batch(i, data):
def g... | Slice inputs into a Dataset of batches.
Given a Dataset of batch indices and the unsliced inputs,
this step slices the inputs in a parallelized fashion
and produces a dataset of input batches.
Args:
indices_dataset: A Dataset of batched indices.
inputs: A python data structure that contains the inputs,
targets, and p... | github-repos |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.