code stringlengths 20 4.93k | docstring stringlengths 33 1.27k | source stringclasses 3
values |
|---|---|---|
def coupling(self, source_y, target_y, weight):
v_pyramidal = source_y[1] - source_y[2]
return (np.array([0, 0, 0, 0, 0, 1.0, 0, 0]) *
(weight*self.g1*self.He2*self.ke2*self.S(v_pyramidal))) | How to couple the output of one node to the input of another.
Args:
source_y (array of shape (8,)): state of the source node
target_y (array of shape (8,)): state of the target node
weight (float): the connection strength
Returns:
input (array of shape (8,)): value to drive each variable of the
target node. | juraj-google-style |
def decode_list_oov(self, ids, source_oov_id_to_token):
seq = (reversed(ids) if self._reverse else ids)
tokens = []
for cur_id in seq:
if (cur_id in self._id_to_token):
tokens.append(self._id_to_token[cur_id])
else:
tokens.append(source_oov_id_to_token[(cur_id - self.... | decode ids back to tokens, considering OOVs temporary IDs.
Args:
ids: vocab ids. Could possibly include source temporary OOV ID starting
from vocab_size.
source_oov_id_to_token: a list of source OOV tokens, with the order the
same as they appear in the source.
Returns:
decoded tokens, possibly including source OOV to... | codesearchnet |
def batch_set_value(tuples):
if context.executing_eagerly() or ops.inside_function():
for x, value in tuples:
x.assign(numpy_compat.np_asarray(value, dtype=dtype_numpy(x)))
else:
with get_graph().as_default():
if tuples:
assign_ops = []
fee... | Sets the values of many tensor variables at once.
Args:
tuples: a list of tuples `(tensor, value)`.
`value` should be a Numpy array. | github-repos |
def get_point_index(self, point):
for i, segment in enumerate(self.segments):
idx = segment.getPointIndex(point)
if idx != -1:
return i, idx
return -1, -1 | Gets of the closest first point
Args:
point (:obj:`Point`)
Returns:
(int, int): Segment id and point index in that segment | juraj-google-style |
def add(TargetGroup, NewMember, Config=None, Args=None):
Member = (Task(NewMember, (Args or {}), (Config or {})) if isfunction(NewMember) else Group(NewMember, (Config or {})))
ParentMembers = TargetGroup.__ec_member__.Members
ParentMembers[Member.Config['name']] = Member
alias = Member.Config.get('alia... | r"""Adds members to an existing group.
Args:
TargetGroup (Group): The target group for the addition.
NewMember (Group / Task): The member to be added.
Config (dict): The config for the member.
Args (OrderedDict): ArgConfig for the NewMember, if it's a task (optional). | codesearchnet |
def coord_list_mapping(subset, superset, atol=1e-08):
c1 = np.array(subset)
c2 = np.array(superset)
inds = np.where(np.all(np.isclose(c1[(:, None, :)], c2[(None, :, :)], atol=atol), axis=2))[1]
result = c2[inds]
if (not np.allclose(c1, result, atol=atol)):
if (not is_coord_subset(subset, sup... | Gives the index mapping from a subset to a superset.
Subset and superset cannot contain duplicate rows
Args:
subset, superset: List of coords
Returns:
list of indices such that superset[indices] = subset | codesearchnet |
def emergence(network, state, do_blackbox=False, do_coarse_grain=True, time_scales=None):
micro_phi = compute.major_complex(network, state).phi
max_phi = float('-inf')
max_network = None
for subsystem in all_macro_systems(network, state, do_blackbox=do_blackbox, do_coarse_grain=do_coarse_grain, time_sca... | Check for the emergence of a micro-system into a macro-system.
Checks all possible blackboxings and coarse-grainings of a system to find
the spatial scale with maximum integrated information.
Use the ``do_blackbox`` and ``do_coarse_grain`` args to specifiy whether to
use blackboxing, coarse-graining, or both. The def... | codesearchnet |
def irreducible_purviews(cm, direction, mechanism, purviews):
def reducible(purview):
'Return ``True`` if purview is trivially reducible.'
(_from, to) = direction.order(mechanism, purview)
return connectivity.block_reducible(cm, _from, to)
return [purview for purview in purviews if (not... | Return all purviews which are irreducible for the mechanism.
Args:
cm (np.ndarray): An |N x N| connectivity matrix.
direction (Direction): |CAUSE| or |EFFECT|.
purviews (list[tuple[int]]): The purviews to check.
mechanism (tuple[int]): The mechanism in question.
Returns:
list[tuple[int]]: All purviews in ``purviews``... | codesearchnet |
def _run_internal_graph(self, inputs, training=None, mask=None):
inputs = self._flatten_to_reference_inputs(inputs)
if mask is None:
masks = [None] * len(inputs)
else:
masks = self._flatten_to_reference_inputs(mask)
for input_t, mask in zip(inputs, masks):
input_t._keras_mask = m... | Computes output tensors for new inputs.
# Note:
- Can be run on non-Keras tensors.
Args:
inputs: Tensor or nested structure of Tensors.
training: Boolean learning phase.
mask: (Optional) Tensor or nested structure of Tensors.
Returns:
output_tensors | github-repos |
def indexes(self, collection=None):
indexes = []
for collection_name in self.collections():
if collection and collection != collection_name:
continue
for index_name in self.db[collection_name].index_information():
if index_name !... | Return a list with the current indexes
Skip the mandatory _id_ indexes
Args:
collection(str)
Returns:
indexes(list) | juraj-google-style |
def do_transaction(args):
rest_client = RestClient(args.url, args.user)
if args.subcommand == 'list':
transactions = rest_client.list_transactions()
keys = ('transaction_id', 'family', 'version', 'size', 'payload')
headers = tuple(k.upper() if k != 'version' else 'VERS' for k in ke... | Runs the transaction list or show command, printing to the console
Args:
args: The parsed arguments sent to the command at runtime | juraj-google-style |
def _should_get_another_batch(self, content):
if ('max-keys' in self._options and
self._options['max-keys'] <= common._MAX_GET_BUCKET_RESULT):
return False
elements = self._find_elements(
content, set([common._T_IS_TRUNCATED,
common._T_NEXT_MARKER]))
if elem... | Whether to issue another GET bucket call.
Args:
content: response XML.
Returns:
True if should, also update self._options for the next request.
False otherwise. | juraj-google-style |
def _get_weight_param_summary(wp):
summary_str = ''
if wp.HasField('quantization'):
nbits = wp.quantization.numberOfBits
quant_type = 'linearly' if wp.quantization.HasField('linearQuantization') else 'lookup-table'
summary_str += '{}-bit {} quantized'.format(nbits, quant_type)
... | Get a summary of _NeuralNetwork_pb2.WeightParams
Args:
wp : _NeuralNetwork_pb2.WeightParams - the _NeuralNetwork_pb2.WeightParams message to display
Returns:
a str summary for wp | juraj-google-style |
def get_aggregation_propensity(self, seq, outdir, cutoff_v=5, cutoff_n=5, run_amylmuts=False):
seq = ssbio.protein.sequence.utils.cast_to_str(seq)
results = self.run_amylpred2(seq=seq, outdir=outdir, run_amylmuts=run_amylmuts)
(agg_index, agg_conf) = self.parse_for_consensus_aggregation(N=len(seq), results=... | Run the AMYLPRED2 web server for a protein sequence and get the consensus result for aggregation propensity.
Args:
seq (str, Seq, SeqRecord): Amino acid sequence
outdir (str): Directory to where output files should be saved
cutoff_v (int): The minimal number of methods that agree on a residue being a aggregation-prone... | codesearchnet |
def decode(token, certs=None, verify=True, audience=None):
(header, payload, signed_section, signature) = _unverified_decode(token)
if (not verify):
return payload
if isinstance(certs, collections.Mapping):
key_id = header.get('kid')
if key_id:
if (key_id not in certs):
... | Decode and verify a JWT.
Args:
token (str): The encoded JWT.
certs (Union[str, bytes, Mapping[str, Union[str, bytes]]]): The
certificate used to validate the JWT signature. If bytes or string,
it must the the public key certificate in PEM format. If a mapping,
it must be a mapping of key IDs to public key certificates... | codesearchnet |
def set_card_standard(self, title, text, smallImageUrl=None, largeImageUrl=None):
self.response.card.type = 'Standard'
self.response.card.title = title
self.response.card.text = text
if smallImageUrl:
self.response.card.image.smallImageUrl = smallImageUrl
if largeImageUrl:
self.respo... | Set response card as standard type.
title, text, and image cannot exceed 8,000 characters.
Args:
title: str. Title of Simple or Standard type card.
text: str. Content of Standard type card.
smallImageUrl: str. URL of small image. Cannot exceed 2,000
characters. Recommended pixel size: 720w x 480h.
largeImageUrl: str.... | codesearchnet |
def bfs(graph, start):
queue = []
visited = []
queue.append([['', start]])
while queue:
path = queue.pop(0)
node = path[-1][1]
if node.stateid not in visited:
visited.append(node.stateid)
if node.final != ... | Finds the shortest string using BFS
Args:
graph (DFA): The DFA states
start (DFA state): The DFA initial state
Returns:
str: The shortest string | juraj-google-style |
def aggregate_kernel_metrics(metrics: list[str], kernel_metrics: list[dict[str, tuple[str, str]]]) -> list[list[str]]:
if not kernel_metrics:
raise app.UsageError('no metrics found')
results: dict[str, tuple[list[float], str]] = {}
for vals in kernel_metrics:
for name in metrics:
... | Aggregates and returns the metrics for the given kernels.
Args:
metrics: list of metrics names to print
kernel_metrics: dictionary of metrics by kernel
Returns:
list of rows [name, value, unit] per metric. | github-repos |
def gather(values, index, name='segmented_gather'):
indices = index.indices
if len(values.shape[index.batch_dims:]) < 2:
return torch.gather(values, index.batch_dims, indices.view(values.size()[0], -1)).view(indices.size())
else:
indices = indices.unsqueeze(-1).expand(values.shape)
r... | Gathers from *values* using the index map. For each element in the domain of the index map this operation looks up
a value for that index in *values*. Two elements from the same segment always get assigned the same value.
Args:
values (`torch.Tensor` of shape (B1, ..., Bn, num_segments, V1, ...)):
Tensor with segment ... | github-repos |
def GenesisBlock() -> Block:
prev_hash = UInt256(data=bytearray(32))
timestamp = int(datetime(2016, 7, 15, 15, 8, 21, tzinfo=pytz.utc).timestamp())
index = 0
consensus_data = 2083236893
next_consensus = Blockchain.GetConsensusAddress(Blockchain.StandbyValidators())
script = Witness(bytearray(0),... | Create the GenesisBlock.
Returns:
BLock: | codesearchnet |
def _prepare_controller(self, controller, template):
if template:
fn = aiohttp_jinja2.template(template_name=template)(controller)
else:
fn = self._parse_json_response(controller)
return fn | Wraps the controller wether to render a jinja template or to return a json response (if template is None)
Args:
controller (coroutine): the coroutine to be wrapped
template (str): the name of the template or None
Returns:
coroutine: a wrapped coroutine of the controller | juraj-google-style |
def GetUnclaimedCoins(self):
unclaimed = []
neo = Blockchain.SystemShare().Hash
for coin in self.GetCoins():
if ((coin.Output.AssetId == neo) and ((coin.State & CoinState.Confirmed) > 0) and ((coin.State & CoinState.Spent) > 0) and ((coin.State & CoinState.Claimed) == 0) and ((coin.State & CoinState... | Gets coins in the wallet that have not been 'claimed', or redeemed for their gas value on the blockchain.
Returns:
list: a list of ``neo.Wallet.Coin`` that have 'claimable' value | codesearchnet |
def _build_parser(self):
main_parser = argparse.ArgumentParser(description=self.common.help, prefix_chars='-+')
self._add_options_to_parser(self._opt_bare, main_parser)
main_parser.set_defaults(**self.common.defaults)
if (self.bare is not None):
main_parser.set_defaults(**self.bare.defaults)
... | Build command line argument parser.
Returns:
:class:`argparse.ArgumentParser`: the command line argument parser.
You probably won't need to use it directly. To parse command line
arguments and update the :class:`ConfigurationManager` instance
accordingly, use the :meth:`parse_args` method. | codesearchnet |
def get_alignment_df(a_aln_seq, b_aln_seq, a_seq_id=None, b_seq_id=None):
if len(a_aln_seq) != len(b_aln_seq):
raise ValueError('Sequence lengths not equal - was an alignment run?')
if not a_seq_id:
a_seq_id = 'a_seq'
if not b_seq_id:
b_seq_id = 'b_seq'
a_aln_seq = ssbio.p... | Summarize two alignment strings in a dataframe.
Args:
a_aln_seq (str): Aligned sequence string
b_aln_seq (str): Aligned sequence string
a_seq_id (str): Optional ID of a_seq
b_seq_id (str): Optional ID of b_aln_seq
Returns:
DataFrame: a per-residue level annotation of the alignment | juraj-google-style |
def from_statements(
cls, sts: List[Influence], assign_default_polarities: bool = True
):
_dict = {}
for s in sts:
if assign_default_polarities:
for delta in deltas(s):
if delta["polarity"] is None:
delta["pola... | Construct an AnalysisGraph object from a list of INDRA statements.
Unknown polarities are set to positive by default.
Args:
sts: A list of INDRA Statements
Returns:
An AnalysisGraph instance constructed from a list of INDRA
statements. | juraj-google-style |
def sample(self, size=None):
self._recompute()
if (size is None):
n = np.random.randn(len(self._t))
else:
n = np.random.randn(len(self._t), size)
n = self.solver.dot_L(n)
if (size is None):
return (self.mean.get_value(self._t) + n[(:, 0)])
return (self.mean.get_value(self... | Sample from the prior distribution over datasets
Args:
size (Optional[int]): The number of samples to draw.
Returns:
array[n] or array[size, n]: The samples from the prior
distribution over datasets. | codesearchnet |
def __init__(self, data, limit=None):
self._data = data
self._limit = limit | Initialise the Action object.
Args:
data (MultiTaskData): The processed data from the task that should be passed
on to successor tasks.
limit (list): A list of names of all immediate successor tasks that
should be executed. | juraj-google-style |
def prepare_loss_functions(loss, output_names):
if isinstance(loss, collections.abc.Mapping):
generic_utils.check_for_unexpected_keys('loss', loss, output_names)
loss_functions = []
for name in output_names:
if name not in loss:
logging.warning('Output {0} missing... | Converts loss to a list of loss functions.
Args:
loss: String (name of objective function), objective function or
`tf.losses.Loss` instance. See `tf.losses`. If the model has multiple
outputs, you can use a different loss on each output by passing a
dictionary or a list of losses. The loss value that will be minimized... | github-repos |
def _parse_test_option_args(self, argv):
parser = argparse.ArgumentParser()
parser.add_argument('--test-pipeline-options', type=str, action='store', help='only run tests providing service options')
parser.add_argument('--not-use-test-runner-api', action='store_true', default=False, help='whether not to use ... | Parse value of command line argument: --test-pipeline-options to get
pipeline options.
Args:
argv: An iterable of command line arguments to be used. If not specified
then sys.argv will be used as input for parsing arguments.
Returns:
An argument list of options that can be parsed by argparser or directly
build a pipe... | github-repos |
def cached_name_scope(name, top_level=True):
if not top_level:
current_ns = tf.get_default_graph().get_name_scope()
if current_ns:
name = current_ns + '/' + name
ns = _get_cached_ns(name)
with tf.name_scope(ns):
yield ns | Return a context which either opens and caches a new name scope,
or reenter an existing one.
Args:
top_level(bool): if True, the name scope will always be top-level.
It will not be nested under any existing name scope of the caller. | juraj-google-style |
def from_backbone_config(cls, backbone_config: PretrainedConfig, **kwargs):
return cls(backbone_config=backbone_config, **kwargs) | Instantiate a [`Mask2FormerConfig`] (or a derived class) from a pre-trained backbone model configuration.
Args:
backbone_config ([`PretrainedConfig`]):
The backbone configuration.
Returns:
[`Mask2FormerConfig`]: An instance of a configuration object | github-repos |
def to_str(value):
if sys.version_info.major < 3 and isinstance(value, six.string_types):
return value
return str(value) | Convert the input to a string, unless it is a unicode string in Python 2.
Unicode strings are supported as native strings in Python 3, but ``str()`` cannot be
invoked on unicode strings in Python 2, so we need to check for that case when
converting user-specified values to strings.
Args:
value: The value to convert t... | juraj-google-style |
def get_idiomatic_name_in_language(cls, name, language):
if (language in cls.idiomatic_methods_cache):
m = cls.idiomatic_methods_cache[language]
if (not m):
return name
return m(name)
(found, method) = load_language_plugins(language, 'get_idiomatic_name')
if found:
... | Get the name for the given language
Args:
name (str): the name to convert
language (str): the language to use
Returns:
a name in the given language
Example:
get_idiomatic_name_in_language("EnterpriseNetwork", "python")
>>> enterprise_network | codesearchnet |
def swo_speed_info(self):
info = structs.JLinkSWOSpeedInfo()
res = self._dll.JLINKARM_SWO_Control(enums.JLinkSWOCommands.GET_SPEED_INFO, ctypes.byref(info))
if (res < 0):
raise errors.JLinkException(res)
return info | Retrieves information about the supported SWO speeds.
Args:
self (JLink): the ``JLink`` instance
Returns:
A ``JLinkSWOSpeedInfo`` instance describing the target's supported
SWO speeds.
Raises:
JLinkException: on error | codesearchnet |
def run(argv=None, save_main_session=True, test_pipeline=None) -> PipelineResult:
known_args, pipeline_args = parse_known_args(argv)
pipeline_options = PipelineOptions(pipeline_args)
pipeline_options.view_as(SetupOptions).save_main_session = save_main_session
model_loader = TFModelHandlerTensor(model_ur... | Args:
argv: Command line arguments defined for this example.
save_main_session: Used for internal testing.
test_pipeline: Used for internal testing. | github-repos |
def _validate_query_parameters(self, query, action_spec):
processed_params = []
for param_name, param_value in query.items():
if param_name in action_spec['parameters'].keys():
processed_params.append(param_name)
if action_spec['para... | Check the query parameter for the action specification.
Args:
query: query parameter to check.
action_spec: specification of the action.
Returns:
True if the query is valid. | juraj-google-style |
def __init__(self, x: int, *args, y: str, **kwargs) -> float:
del x, y, args, kwargs | Constructor.
Args:
x: Input 1.
*args: Variable positional args.
y: Input 2.
**kwargs: Variable keyword args.
Returns:
The result. | github-repos |
def get_poi(self, **kwargs):
params = {
'coordinateX': kwargs.get('longitude'),
'coordinateY': kwargs.get('latitude'),
'tipos': util.ints_to_string(kwargs.get('types')),
'Radius': kwargs.get('radius'),
'cultureInfo': util.language_cod... | Obtain a list of POI in the given radius.
Args:
latitude (double): Latitude in decimal degrees.
longitude (double): Longitude in decimal degrees.
types (list[int] | int): POI IDs (or empty list to get all).
radius (int): Radius (in meters) of the search.
lang (str): Language code (*es* or *en*).
Returns:
Status boole... | juraj-google-style |
def tar_extract(context):
logger.debug('start')
mode = get_file_mode_for_reading(context)
for item in context['tar']['extract']:
source = context.get_formatted_string(item['in'])
destination = context.get_formatted_string(item['out'])
with tarfile.open(source, mode) as extract_me:
... | Extract all members of tar archive to specified path.
Args:
context: dictionary-like. context is mandatory.
context['tar']['extract'] must exist. It's a dictionary.
keys are the path to the tar to extract.
values are the destination paths.
Example:
tar:
extract:
- in: path/to/my.tar.xs
out: /path/extract/here
- in: a... | codesearchnet |
def _get_object_from_version(cls, operations, ident):
version, objname = ident.split(".")
module_ = operations.get_context().script.get_revision(version).module
obj = getattr(module_, objname)
return obj | Returns a Python object from an Alembic migration module (script).
Args:
operations: instance of ``alembic.operations.base.Operations``
ident: string of the format ``version.objname``
Returns:
the object whose name is ``objname`` within the Alembic migration
script identified by ``version`` | juraj-google-style |
def Trim(self):
ms = StreamManager.GetStream()
writer = BinaryWriter(ms)
self.SerializeUnsigned(writer)
writer.WriteByte(1)
self.Script.Serialize(writer)
writer.WriteHashes([tx.Hash.ToBytes() for tx in self.Transactions])
retVal = ms.ToArray()
StreamManager.ReleaseStream(ms)
return r... | Returns a byte array that contains only the block header and transaction hash.
Returns:
bytes: | codesearchnet |
def as_dict_summary(self, print_subelectrodes=True):
chg_comp = self.fully_charged_entry.composition
dischg_comp = self.fully_discharged_entry.composition
ion = self.working_ion
d = {'average_voltage': self.get_average_voltage(), 'max_voltage': self.max_voltage, 'min_voltage': self.min_voltage, 'max_del... | Generate a summary dict.
Args:
print_subelectrodes: Also print data on all the possible
subelectrodes.
Returns:
A summary of this electrode"s properties in dict format. | codesearchnet |
def target_optimizer_arguments(self):
variables = (self.target_network.get_variables() + [variable for name in sorted(self.target_distributions) for variable in self.target_distributions[name].get_variables()])
source_variables = (self.network.get_variables() + [variable for name in sorted(self.distributions) f... | Returns the target optimizer arguments including the time, the list of variables to
optimize, and various functions which the optimizer might require to perform an update
step.
Returns:
Target optimizer arguments as dict. | codesearchnet |
def define_singleton(carrier, name, cls, cls_args={}):
instance_name = '__{}'.format(name)
setattr(carrier, instance_name, None)
def getter(self):
instance = getattr(carrier, instance_name)
if (instance is None):
instance = cls(**cls_args)
setattr(carrier, instance_n... | Creates a property with the given name, but the cls will created only with the first call
Args:
carrier: an instance of the class where want to reach the cls instance
name (str): the variable name of the cls instance
cls (type): the singleton object type
cls_args (dict): optional dict for createing cls | codesearchnet |
async def from_api_token(cls, token=None, api_cls=SlackBotApi):
api = api_cls.from_env() if token is None else api_cls(api_token=token)
data = await api.execute_method(cls.API_AUTH_ENDPOINT)
return cls(data['user_id'], data['user'], api) | Create a new instance from the API token.
Arguments:
token (:py:class:`str`, optional): The bot's API token
(defaults to ``None``, which means looking in the
environment).
api_cls (:py:class:`type`, optional): The class to create
as the ``api`` argument for API access (defaults to
:py:class:`aslack.slack_api.SlackBotA... | juraj-google-style |
def inner(x1, x2):
if any_symbolic_tensors((x1, x2)):
return Inner().symbolic_call(x1, x2)
return backend.numpy.inner(x1, x2) | Return the inner product of two tensors.
Ordinary inner product of vectors for 1-D tensors
(without complex conjugation), in higher dimensions
a sum product over the last axes.
Multidimensional arrays are treated as vectors by flattening
all but their last axes. The resulting dot product is performed
over their last ... | github-repos |
def count_params(weights):
unique_weights = {id(w): w for w in weights}.values()
weight_shapes = [w.shape.as_list() for w in unique_weights]
standardized_weight_shapes = [[0 if w_i is None else w_i for w_i in w] for w in weight_shapes]
return int(sum((np.prod(p) for p in standardized_weight_shapes))) | Count the total number of scalars composing the weights.
Args:
weights: An iterable containing the weights on which to compute params
Returns:
The total number of scalars composing the weights | github-repos |
def dump_ddl(metadata: MetaData,
dialect_name: str,
fileobj: TextIO = sys.stdout,
checkfirst: bool = True) -> None:
def dump(querysql, *multiparams, **params):
compsql = querysql.compile(dialect=engine.dialect)
writeline_nl(fileobj, "{s... | Sends schema-creating DDL from the metadata to the dump engine.
This makes ``CREATE TABLE`` statements.
Args:
metadata: SQLAlchemy :class:`MetaData`
dialect_name: string name of SQL dialect to generate DDL in
fileobj: file-like object to send DDL to
checkfirst: if ``True``, use ``CREATE TABLE IF NOT EXISTS`` or
equiva... | juraj-google-style |
def choose_palette(stream=sys.stdout, basic_palette=None):
result = None
pal = basic_palette
log.debug('console version: %s', __version__)
log.debug('X11_RGB_PATHS: %r', X11_RGB_PATHS)
if color_is_forced():
(result, pal) = (detect_palette_support(basic_palette=pal) or 'basic')
elif (is_a... | Make a best effort to automatically determine whether to enable
ANSI sequences, and if so, which color palettes are available.
This is the main function of the module—meant to be used unless
something more specific is needed.
Takes the following factors into account:
- Whether output stream is a TTY.
- ``TERM``, ``A... | codesearchnet |
def Increment(self, key):
with self._lock:
if _IsHashable(key):
if key in self._d:
self._d[key] += 1
else:
self._d[key] = 1
else:
try:
i = self._unhashable_items.index(key)
self._unhashable_counts[i] ... | Atomically increment a count by 1. Insert the item if not present.
Args:
key: the key being counted. | github-repos |
def sort_prefixes(orig, prefixes='@+'):
new = ''
for prefix in prefixes:
if (prefix in orig):
new += prefix
return new | Returns a sorted list of prefixes.
Args:
orig (str): Unsorted list of prefixes.
prefixes (str): List of prefixes, from highest-priv to lowest. | codesearchnet |
def get_all_models_including_attached_models(model):
if (hasattr(model, "_tx_model_repository")):
models = list(
model._tx_model_repository.all_models.filename_to_model.values())
if model not in models:
models.append(model)
else:
models = [model]
return m... | get a list of all models stored within a model
(including the owning model).
Args:
model: the owning model
Returns:
a list of all models | juraj-google-style |
def dump(self):
return {u'storage_data': [x.asdict() for x in self.storage_data], u'streaming_data': [x.asdict() for x in self.streaming_data]} | Serialize the state of this InMemoryStorageEngine to a dict.
Returns:
dict: The serialized data. | codesearchnet |
def mktemp(self, container: Container) -> str:
r = self.__api.post('containers/{}/tempfile'.format(container.uid))
if (r.status_code == 200):
return r.json()
self.__api.handle_erroneous_response(r) | Generates a temporary file for a given container.
Returns:
the path to the temporary file inside the given container. | codesearchnet |
def lsfiles(root=".", **kwargs):
paths = ls(root=root, **kwargs)
if isfile(root):
return paths
return [_path for _path in paths if isfile(path(root, _path))] | Return only files from a directory listing.
Arguments:
root (str): Path to directory. Can be relative or absolute.
**kwargs: Any additional arguments to be passed to ls().
Returns:
list of str: A list of file paths.
Raises:
OSError: If root directory does not exist. | juraj-google-style |
def send_rpc_sync(self, conn_id, address, rpc_id, payload, timeout):
done = threading.Event()
result = {}
def send_rpc_done(conn_id, adapter_id, status, reason, rpc_status, resp_payload):
result['success'] = status
result['failure_reason'] = reason
result['status'] = rpc_status
... | Synchronously send an RPC to this IOTile device
Args:
conn_id (int): A unique identifier that will refer to this connection
address (int): the address of the tile that we wish to send the RPC to
rpc_id (int): the 16-bit id of the RPC we want to call
payload (bytearray): the payload of the command
timeout (float): the ... | codesearchnet |
def create_fork_relation(self, forked_from_id, **kwargs):
path = '/projects/%s/fork/%s' % (self.get_id(), forked_from_id)
self.manager.gitlab.http_post(path, **kwargs) | Create a forked from/to relation between existing projects.
Args:
forked_from_id (int): The ID of the project that was forked from
**kwargs: Extra options to send to the server (e.g. sudo)
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabCreateError: If the relation could not be created | juraj-google-style |
def find(self, name):
for i in range(0, len(self)):
if self[i].name == name:
return i
return -1 | Get the index of a field in the flattened list given its (fully-qualified) name.
Args:
name: the fully-qualified name of the field.
Returns:
The index of the field, if found; else -1. | juraj-google-style |
def ParseFileObject(self, parser_mediator, file_object):
filename = parser_mediator.GetFilename()
file_size = file_object.get_size()
if file_size <= 0:
raise errors.UnableToParseFile(
'File size: {0:d} bytes is less equal 0.'.format(file_size))
if file_size > 50000000:
... | Parses a plist file-like object.
Args:
parser_mediator (ParserMediator): mediates interactions between parsers
and other components, such as storage and dfvfs.
file_object (dfvfs.FileIO): a file-like object.
Raises:
UnableToParseFile: when the file cannot be parsed. | juraj-google-style |
def add_note(self, note):
notes = self.cached_json
if not note.moderator:
note.moderator = self.r.user.me().name
try:
mod_index = notes['constants']['users'].index(note.moderator)
except ValueError:
notes['constants']['user... | Add a note to the usernotes wiki page.
Arguments:
note: the note to be added (Note)
Returns the update message for the usernotes wiki
Raises:
ValueError when the warning type of the note can not be found in the
stored list of warnings. | juraj-google-style |
def get_status_tree(root_pipeline_id):
root_pipeline_key = db.Key.from_path(_PipelineRecord.kind(), root_pipeline_id)
root_pipeline_record = db.get(root_pipeline_key)
if (root_pipeline_record is None):
raise PipelineStatusError(('Could not find pipeline ID "%s"' % root_pipeline_id))
actual_root_... | Gets the full status tree of a pipeline.
Args:
root_pipeline_id: The pipeline ID to get status for.
Returns:
Dictionary with the keys:
rootPipelineId: The ID of the root pipeline.
slots: Mapping of slot IDs to result of from _get_internal_slot.
pipelines: Mapping of pipeline IDs to result of _get_internal_status.
Ra... | codesearchnet |
def splat(f: Callable[(..., A)]) -> Callable[([Iterable], A)]:
def splatted(args):
return f(*args)
return splatted | Convert a function taking multiple arguments into a function taking a single iterable argument.
Args:
f: Any function
Returns:
A function that accepts a single iterable argument. Each element of this iterable argument is passed as an
argument to ``f``.
Example:
$ def f(a, b, c):
$ return a + b + c
$
$ f(1, 2, 3)... | codesearchnet |
def Analyze(self, hashes):
logger.debug(
'Opening connection to {0:s}:{1:d}'.format(self._host, self._port))
nsrl_socket = self._GetSocket()
if not nsrl_socket:
self.SignalAbort()
return []
hash_analyses = []
for digest in hashes:
response = self._QueryHash(nsrl_sock... | Looks up hashes in nsrlsvr.
Args:
hashes (list[str]): hash values to look up.
Returns:
list[HashAnalysis]: analysis results, or an empty list on error. | juraj-google-style |
def set_hyperparameters(self, hyperparameters):
for block_name, block_hyperparams in hyperparameters.items():
self.blocks[block_name].set_hyperparameters(block_hyperparams) | Set new hyperparameter values for some blocks.
Args:
hyperparameters (dict): A dictionary containing the block names as
keys and the new hyperparameters dictionary
as values. | juraj-google-style |
def _prepare_for_training(self, job_name=None):
super(Framework, self)._prepare_for_training(job_name=job_name)
if (self.source_dir and (not self.source_dir.lower().startswith('s3:
validate_source_dir(self.entry_point, self.source_dir)
local_code = get_config_value('local.local_code', self.sagemaker... | Set hyperparameters needed for training. This method will also validate ``source_dir``.
Args:
* job_name (str): Name of the training job to be created. If not specified, one is generated,
using the base name given to the constructor if applicable. | codesearchnet |
def main(jlink_serial, device):
buf = StringIO.StringIO()
jlink = pylink.JLink(log=buf.write, detailed_log=buf.write)
jlink.open(serial_no=jlink_serial)
jlink.set_tif(pylink.enums.JLinkInterfaces.SWD)
jlink.connect(device, verbose=True)
sys.stdout.write('ARM Id: %d\n' % jlink.core_id... | Prints the core's information.
Args:
jlink_serial (str): the J-Link serial number
device (str): the target CPU
Returns:
Always returns ``0``.
Raises:
JLinkException: on error | juraj-google-style |
def pull(self, device_filename, dest_file=None, timeout_ms=None):
should_return_data = (dest_file is None)
if isinstance(dest_file, six.string_types):
dest_file = open(dest_file, 'w')
elif (dest_file is None):
dest_file = six.StringIO()
self.filesync_service.recv(device_filename, dest_fi... | Pull file from device.
Arguments:
device_filename: The filename on the device to pull.
dest_file: If set, a filename or writable file-like object.
timeout_ms: Expected timeout for the pull.
Returns:
The file data if dest_file is not set, None otherwise. | codesearchnet |
def get_bq_tableschema(schema):
if isinstance(schema, (bigquery.TableSchema, value_provider.ValueProvider)) or callable(schema) or schema is None:
return schema
elif isinstance(schema, str):
return get_table_schema_from_string(schema)
elif isinstance(schema, dict):
schema_string = js... | Convert the table schema to a TableSchema object.
Args:
schema (str, dict, ~apache_beam.io.gcp.internal.clients.bigquery.bigquery_v2_messages.TableSchema):
The schema to be used if the BigQuery table to write has to be created.
This can either be a dict or string or in the TableSchema format.
Returns:
~apache_beam.io... | github-repos |
def __init__(self, scope, parent, id, name, result, definition=True):
CodeEntity.__init__(self, scope, parent)
self.id = id
self.name = name
self.result = result
self.parameters = []
self.body = CodeBlock(self, self, explicit=True)
self.member_of = None
... | Constructor for functions.
Args:
scope (CodeEntity): The program scope where this object belongs.
parent (CodeEntity): This object's parent in the program tree.
id: An unique identifier for this function.
name (str): The name of the function in the program.
result (str): The return type of the function in the program. | juraj-google-style |
def get_lagged_subsequences(self, sequence: torch.Tensor, subsequences_length: int, shift: int=0) -> torch.Tensor:
sequence_length = sequence.shape[1]
indices = [lag - shift for lag in self.config.lags_sequence]
if max(indices) + subsequences_length > sequence_length:
raise ValueError(f'lags cannot ... | Returns lagged subsequences of a given sequence. Returns a tensor of shape (N, S, C, I),
where S = subsequences_length and I = len(indices), containing lagged subsequences. Specifically, lagged[i,
j, :, k] = sequence[i, -indices[k]-S+j, :].
Args:
sequence: Tensor
The sequence from which lagged subsequences should be e... | github-repos |
def check_target_module_exists(optim_target_modules, key: str, return_is_regex: bool=False):
target_module_found = False
is_regex = False
if isinstance(optim_target_modules, str):
target_module_found = bool(re.fullmatch(optim_target_modules, key))
is_regex = True if not optim_target_modules ... | A helper method to check if the passed module's key name matches any of the target modules in the optim_target_modules.
Args:
optim_target_modules (`Union[str, List[str]]`):
A list of strings to try to match. Can be also a full string.
key (`str`):
A key to search any matches in optim_target_modules
return_is_regex (`... | github-repos |
def pgm(X, prox_f, step_f, accelerated=False, relax=None, e_rel=1e-06, max_iter=1000, traceback=None):
stepper = utils.NesterovStepper(accelerated=accelerated)
if (relax is not None):
assert ((relax > 0) and (relax < 1.5))
if (traceback is not None):
traceback.update_history(0, X=X, step_f=s... | Proximal Gradient Method
Adapted from Combettes 2009, Algorithm 3.4.
The accelerated version is Algorithm 3.6 with modifications
from Xu & Yin (2015).
Args:
X: initial X, will be updated
prox_f: proxed function f (the forward-backward step)
step_f: step size, < 1/L with L being the Lipschitz constant of grad f
accele... | codesearchnet |
def CopyConfig(self):
newconf = self.MakeNewConfig()
newconf.raw_data = copy.deepcopy(self.raw_data)
newconf.files = copy.deepcopy(self.files)
newconf.secondary_config_parsers = copy.deepcopy(self.secondary_config_parsers)
newconf.writeback = copy.deepcopy(self.writeback)
newconf.writeback_data ... | Make a complete new copy of the current config.
This includes all options as they currently are. If you want a base config
with defaults use MakeNewConfig.
Returns:
A new config object with the same data as self. | codesearchnet |
def create_requests(
requests: Union[Dict, List], *, context: Any = NOCONTEXT, convert_camel_case: bool
) -> Union[Request, Set[Request]]:
if isinstance(requests, list):
return {
Request(context=context, convert_camel_case=convert_camel_case, **request)
for request in reques... | Create a Request object from a dictionary (or list of them).
Args:
requests: Request object, or a collection of them.
methods: The list of methods that can be called.
context: If specified, will be the first positional argument in all requests.
convert_camel_case: Will convert the method name/any named params to snake... | juraj-google-style |
def Serialize(self, writer):
writer.WriteUInt32(self.Magic)
writer.WriteFixedString(self.Command, 12)
writer.WriteUInt32(len(self.Payload))
writer.WriteUInt32(self.Checksum)
writer.WriteBytes(self.Payload) | Serialize object.
Args:
writer (neo.IO.BinaryWriter): | juraj-google-style |
def seek(self, offset, whence=os.SEEK_SET):
if not self._gzip_file_object:
raise IOError('Not opened.')
if whence == os.SEEK_CUR:
offset += self._current_offset
elif whence == os.SEEK_END:
offset += self.uncompressed_data_size
elif whence != os.SEEK_SET:
raise IOError('Unsu... | Seeks to an offset within the file-like object.
Args:
offset (int): offset to seek to.
whence (Optional(int)): value that indicates whether offset is an absolute
or relative position within the file.
Raises:
IOError: if the seek failed or the file has not been opened.
OSError: if the seek failed or the file has not b... | juraj-google-style |
def removeRouterPrefix(self, prefixEntry):
print '%s call removeRouterPrefix' % self.port
print prefixEntry
prefix = self.__convertIp6PrefixStringToIp6Address(str(prefixEntry))
try:
prefixLen = 64
cmd = 'prefix remove %s/%d' % (prefix, prefixLen)
... | remove the configured prefix on a border router
Args:
prefixEntry: a on-mesh prefix entry
Returns:
True: successful to remove the prefix entry from border router
False: fail to remove the prefix entry from border router | juraj-google-style |
def orient_averaged_fixed(tm):
S = np.zeros((2, 2), dtype=complex)
Z = np.zeros((4, 4))
ap = np.linspace(0, 360, (tm.n_alpha + 1))[:(- 1)]
aw = (1.0 / tm.n_alpha)
for alpha in ap:
for (beta, w) in zip(tm.beta_p, tm.beta_w):
(S_ang, Z_ang) = tm.get_SZ_single(alpha=alpha, beta=beta... | Compute the T-matrix using variable orientation scatterers.
This method uses a fast Gaussian quadrature and is suitable
for most use. Uses the set particle orientation PDF, ignoring
the alpha and beta attributes.
Args:
tm: TMatrix (or descendant) instance.
Returns:
The amplitude (S) and phase (Z) matrices. | codesearchnet |
def compute_stats(input_handle, stats_path, max_rows=None, for_eval=False, pipeline_args=None, publish_to_bq=None, metrics_dataset=None, metrics_table=None, project=None):
namespace = metrics_table
pipeline = beam.Pipeline(argv=pipeline_args)
metrics_monitor = None
if publish_to_bq:
metrics_moni... | Computes statistics on the input data.
Args:
input_handle: BigQuery table name to process specified as DATASET.TABLE or
path to csv file with input data.
stats_path: Directory in which stats are materialized.
max_rows: Number of rows to query from BigQuery
for_eval: Query for eval set rows from BigQuery
pipeline_args:... | github-repos |
def from_operator(cls, operator):
validation_fields = ('is_non_singular', 'is_self_adjoint', 'is_positive_definite', 'is_square')
kwargs = _extract_attrs(operator, keys=set(operator._composite_tensor_fields + validation_fields))
non_tensor_params = {}
param_specs = {}
for k, v in list(kwargs.items()... | Builds a `_LinearOperatorSpec` from a `LinearOperator` instance.
Args:
operator: An instance of `LinearOperator`.
Returns:
linear_operator_spec: An instance of `_LinearOperatorSpec` to be used as
the `TypeSpec` of `operator`. | github-repos |
def traverse(self, index=0):
if index < len(self.nodes):
for entity in self.nodes[index]:
for next_result in self.traverse(index=index+1):
if isinstance(entity, list):
yield entity + next_result
else:
... | This is used to produce a list of lists where each each item
in that list is a diffrent combination of items from the lists
within with every combination of such values.
Args:
index (int) : the index at witch to start the list.
Note this is used only in the function as a processing
Returns:
list : is every combinatio... | juraj-google-style |
def __init__(self, output_mediator):
super(SQLite4n6TimeOutputModule, self).__init__(output_mediator)
self._connection = None
self._count = 0
self._cursor = None
self._filename = None | Initializes the output module object.
Args:
output_mediator (OutputMediator): output mediator.
Raises:
ValueError: if the file handle is missing. | juraj-google-style |
def current(sam=False):
try:
if sam:
user_name = win32api.GetUserNameEx(win32con.NameSamCompatible)
else:
user_name = win32api.GetUserName()
except pywintypes.error as exc:
log.error('Failed to get current user')
log.error('nbr: %s', exc.winerror)
... | Get the username that salt-minion is running under. If salt-minion is
running as a service it should return the Local System account. If salt is
running from a command prompt it should return the username that started the
command prompt.
.. versionadded:: 2015.5.6
Args:
sam (bool, optional): False returns just the us... | codesearchnet |
def openbin(self, path, mode='r', buffering=(- 1), **options):
self.check()
_path = self.validatepath(path)
_mode = Mode(mode)
_mode.validate_bin()
with self._lock:
if _mode.exclusive:
if self.exists(_path):
raise errors.FileExists(path)
else:
... | Open a binary file-like object.
Arguments:
path (str): A path on the filesystem.
mode (str): Mode to open the file (must be a valid, non-text mode).
Since this method only opens binary files, the ``b`` in the mode
is implied.
buffering (int): the buffering policy (-1 to use default buffering,
0 to disable completely, ... | codesearchnet |
def bessel_y1(x, name=None):
with ops.name_scope(name, 'bessel_y1', [x]):
return gen_special_math_ops.bessel_y1(x) | Computes the Bessel y1 function of `x` element-wise.
Modified Bessel function of order 1.
>>> tf.math.special.bessel_y1([0.5, 1., 2., 4.]).numpy()
array([-1.47147239, -0.78121282, -0.10703243, 0.39792571], dtype=float32)
Args:
x: A `Tensor` or `SparseTensor`. Must be one of the following types: `half`,
`float32`, `... | github-repos |
def get_generation_mode(self, assistant_model: Optional['PreTrainedModel']=None) -> GenerationMode:
if self.constraints is not None or self.force_words_ids is not None:
generation_mode = GenerationMode.CONSTRAINED_BEAM_SEARCH
elif self.num_beams == 1:
if self.do_sample is False:
if s... | Returns the generation mode triggered by the [`GenerationConfig`] instance.
Arg:
assistant_model (`PreTrainedModel`, *optional*):
The assistant model to be used for assisted generation. If set, the generation mode will be
assisted generation.
Returns:
`GenerationMode`: The generation mode triggered by the instance. | github-repos |
def secure(cls):
builtin_mechs = cls._get_builtin_mechanisms()
secure_mechs = [mech for (_, mech) in builtin_mechs.items() if ((not mech.insecure) and (mech.priority is not None))]
return SASLAuth(secure_mechs) | Uses only authentication mechanisms that are secure for use in
non-encrypted sessions.
Returns:
A new :class:`SASLAuth` object. | codesearchnet |
def _ParseTimestamp(self, parser_mediator, row):
timestamp = row.get('timestamp', None)
if (timestamp is not None):
try:
timestamp = int(timestamp, 10)
except (ValueError, TypeError):
parser_mediator.ProduceExtractionWarning('Unable to parse timestamp value: {0!s}'.format... | Provides a timestamp for the given row.
If the Trend Micro log comes from a version that provides a POSIX timestamp,
use that directly; it provides the advantages of UTC and of second
precision. Otherwise fall back onto the local-timezone date and time.
Args:
parser_mediator (ParserMediator): mediates interactions be... | codesearchnet |
def build_results(self, values):
raise NotImplementedError('build_results must be implemented by subclasses') | Build results that match the original shape of the fetch.
Args:
values: List of values returned by run(). The values correspond exactly to
the list tensors or ops returned by unique_fetches().
Returns:
A struct of the same shape as the original fetch object handled by
this fetch mapper. In the returned struct, the o... | github-repos |
def add_send_message(self, connection, send_message):
self._send_message[connection] = send_message
LOGGER.debug('Added send_message function for connection %s', connection) | Adds a send_message function to the Dispatcher's
dictionary of functions indexed by connection.
Args:
connection (str): A locally unique identifier
provided by the receiver of messages.
send_message (fn): The method that should be called
by the dispatcher to respond to messages which
arrive via connection. | codesearchnet |
def to_html(self):
if self.items is None:
return
else:
html = '<ol%s>\n' % self.html_attributes()
for item in self.items:
html += '<li>%s</li>\n' % item.to_html()
html += '</ol>'
return html | Render a Text MessageElement as html
Args:
None
Returns:
Str the html representation of the Text MessageElement
Raises:
Errors are propagated | juraj-google-style |
def add_package(package, ignore_check=False, prevent_pending=False, image=None, restart=False):
cmd = ['DISM', '/Quiet', ('/Image:{0}'.format(image) if image else '/Online'), '/Add-Package', '/PackagePath:{0}'.format(package)]
if ignore_check:
cmd.append('/IgnoreCheck')
if prevent_pending:
c... | Install a package using DISM
Args:
package (str):
The package to install. Can be a .cab file, a .msu file, or a folder
.. note::
An `.msu` package is supported only when the target image is
offline, either mounted or applied.
ignore_check (Optional[bool]):
Skip installation of the package if the applicability checks... | codesearchnet |
def read(self, input_stream, kmip_version=enums.KMIPVersion.KMIP_1_0):
super(KeyWrappingData, self).read(
input_stream,
kmip_version=kmip_version
)
local_stream = BytearrayStream(input_stream.read(self.length))
if self.is_tag_next(enums.Tags.WRAPPING_MET... | Read the data encoding the KeyWrappingData struct and decode it into
its constituent parts.
Args:
input_stream (stream): A data stream containing encoded object
data, supporting a read method; usually a BytearrayStream
object.
kmip_version (KMIPVersion): An enumeration defining the KMIP
version with which the object w... | juraj-google-style |
def AddBasicOptions(self, argument_group):
version_string = self.GetVersionInformation()
argument_group.add_argument('-h', '--help', action='help', help='Show this help message and exit.')
argument_group.add_argument('--troubles', dest='show_troubleshooting', action='store_true', default=False, help='Show t... | Adds the basic options to the argument group.
Args:
argument_group (argparse._ArgumentGroup): argparse argument group. | codesearchnet |
def get_dict(self, name, default=None):
if name not in self:
if default is not None:
return default
raise EnvironmentError.not_found(self._prefix, name)
return dict(**self.get(name)) | Retrieves an environment variable value as a dictionary.
Args:
name (str): The case-insensitive, unprefixed variable name.
default: If provided, a default value will be returned
instead of throwing ``EnvironmentError``.
Returns:
dict: The environment variable's value as a ``dict``.
Raises:
EnvironmentError: If the e... | juraj-google-style |
def make_mixture_prior(latent_size, mixture_components):
if (mixture_components == 1):
return tfd.MultivariateNormalDiag(loc=tf.zeros([latent_size]), scale_identity_multiplier=1.0)
loc = tf.compat.v1.get_variable(name='loc', shape=[mixture_components, latent_size])
raw_scale_diag = tf.compat.v1.get_... | Creates the mixture of Gaussians prior distribution.
Args:
latent_size: The dimensionality of the latent representation.
mixture_components: Number of elements of the mixture.
Returns:
random_prior: A `tfd.Distribution` instance representing the distribution
over encodings in the absence of any evidence. | codesearchnet |
def clip_and_copy_attack_outputs(self, attack_name, is_targeted):
if is_targeted:
self._targeted_attack_names.add(attack_name)
else:
self._attack_names.add(attack_name)
attack_dir = os.path.join(self.targeted_attacks_output_dir
if is_targeted
... | Clips results of attack and copy it to directory with all images.
Args:
attack_name: name of the attack.
is_targeted: if True then attack is targeted, otherwise non-targeted. | juraj-google-style |
def FinalizeTaskStorage(self, task):
if self._storage_type != definitions.STORAGE_TYPE_SESSION:
raise IOError('Unsupported storage type.')
storage_file_path = self._GetTaskStorageFilePath(task)
processed_storage_file_path = self._GetProcessedStorageFilePath(task)
try:
os.rename(storag... | Finalizes a processed task storage.
Moves the task storage file from its temporary directory to the processed
directory.
Args:
task (Task): task.
Raises:
IOError: if the storage type is not supported or
if the storage file cannot be renamed.
OSError: if the storage type is not supported or
if the storage file cannot... | juraj-google-style |
def create_app(self):
self.appinfo['accounts'] = self.get_accounts()
self.log.debug('Pipeline Config\n%s', pformat(self.pipeline_config))
self.log.debug('App info:\n%s', pformat(self.appinfo))
jsondata = self.retrieve_template()
wait_for_task(jsondata)
self.log.info('Successfully created %s appl... | Send a POST to spinnaker to create a new application with class variables.
Raises:
AssertionError: Application creation failed. | codesearchnet |
def FromHttpToTimestamp(self, http_ts_string):
t = time.strptime(http_ts_string, '%a, %d %b %Y %H:%M:%S GMT')
return int(calendar.timegm(t)) | Converts HTTP timestamp string to internal nss_cache timestamp.
Args:
HTTP format timestamp string
Returns:
number of seconds since epoch | github-repos |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.