body
stringlengths
26
98.2k
body_hash
int64
-9,222,864,604,528,158,000
9,221,803,474B
docstring
stringlengths
1
16.8k
path
stringlengths
5
230
name
stringlengths
1
96
repository_name
stringlengths
7
89
lang
stringclasses
1 value
body_without_docstring
stringlengths
20
98.2k
@classmethod def build_model(cls, args, task): 'Build a new model instance.' base_architecture(args) if (not hasattr(args, 'max_source_positions')): args.max_source_positions = DEFAULT_MAX_SOURCE_POSITIONS if (not hasattr(args, 'max_target_positions')): args.max_target_positions = DEFAUL...
2,152,914,506,224,695,600
Build a new model instance.
models/transformer.py
build_model
NCTUMLlab/Adversarial-Masking-Transformers-for-Language-Understanding
python
@classmethod def build_model(cls, args, task): base_architecture(args) if (not hasattr(args, 'max_source_positions')): args.max_source_positions = DEFAULT_MAX_SOURCE_POSITIONS if (not hasattr(args, 'max_target_positions')): args.max_target_positions = DEFAULT_MAX_TARGET_POSITIONS (s...
def forward(self, src_tokens, src_lengths): "\n Args:\n src_tokens (LongTensor): tokens in the source language of shape\n `(batch, src_len)`\n src_lengths (torch.LongTensor): lengths of each source sentence of\n shape `(batch)`\n\n Returns:\n ...
8,721,051,598,448,000,000
Args: src_tokens (LongTensor): tokens in the source language of shape `(batch, src_len)` src_lengths (torch.LongTensor): lengths of each source sentence of shape `(batch)` Returns: dict: - **encoder_out** (Tensor): the last encoder layer's output of shape `(src_len, batch,...
models/transformer.py
forward
NCTUMLlab/Adversarial-Masking-Transformers-for-Language-Understanding
python
def forward(self, src_tokens, src_lengths): "\n Args:\n src_tokens (LongTensor): tokens in the source language of shape\n `(batch, src_len)`\n src_lengths (torch.LongTensor): lengths of each source sentence of\n shape `(batch)`\n\n Returns:\n ...
def reorder_encoder_out(self, encoder_out, bert_outs, new_order): '\n Reorder encoder output according to *new_order*.\n\n Args:\n encoder_out: output from the ``forward()`` method\n new_order (LongTensor): desired order\n\n Returns:\n *encoder_out* rearranged a...
-4,539,497,251,350,111,000
Reorder encoder output according to *new_order*. Args: encoder_out: output from the ``forward()`` method new_order (LongTensor): desired order Returns: *encoder_out* rearranged according to *new_order*
models/transformer.py
reorder_encoder_out
NCTUMLlab/Adversarial-Masking-Transformers-for-Language-Understanding
python
def reorder_encoder_out(self, encoder_out, bert_outs, new_order): '\n Reorder encoder output according to *new_order*.\n\n Args:\n encoder_out: output from the ``forward()`` method\n new_order (LongTensor): desired order\n\n Returns:\n *encoder_out* rearranged a...
def max_positions(self): 'Maximum input length supported by the encoder.' if (self.embed_positions is None): return self.max_source_positions return min(self.max_source_positions, self.embed_positions.max_positions())
-5,228,954,016,557,509,000
Maximum input length supported by the encoder.
models/transformer.py
max_positions
NCTUMLlab/Adversarial-Masking-Transformers-for-Language-Understanding
python
def max_positions(self): if (self.embed_positions is None): return self.max_source_positions return min(self.max_source_positions, self.embed_positions.max_positions())
def upgrade_state_dict_named(self, state_dict, name): 'Upgrade a (possibly old) state dict for new versions of fairseq.' if isinstance(self.embed_positions, SinusoidalPositionalEmbedding): weights_key = '{}.embed_positions.weights'.format(name) if (weights_key in state_dict): del sta...
6,001,696,072,670,587,000
Upgrade a (possibly old) state dict for new versions of fairseq.
models/transformer.py
upgrade_state_dict_named
NCTUMLlab/Adversarial-Masking-Transformers-for-Language-Understanding
python
def upgrade_state_dict_named(self, state_dict, name): if isinstance(self.embed_positions, SinusoidalPositionalEmbedding): weights_key = '{}.embed_positions.weights'.format(name) if (weights_key in state_dict): del state_dict[weights_key] state_dict['{}.embed_positions._float...
def forward(self, src_tokens, src_lengths, bert_encoder_out): "\n Args:\n src_tokens (LongTensor): tokens in the source language of shape\n `(batch, src_len)`\n src_lengths (torch.LongTensor): lengths of each source sentence of\n shape `(batch)`\n\n ...
546,859,358,158,450,940
Args: src_tokens (LongTensor): tokens in the source language of shape `(batch, src_len)` src_lengths (torch.LongTensor): lengths of each source sentence of shape `(batch)` Returns: dict: - **encoder_out** (Tensor): the last encoder layer's output of shape `(src_len, batch,...
models/transformer.py
forward
NCTUMLlab/Adversarial-Masking-Transformers-for-Language-Understanding
python
def forward(self, src_tokens, src_lengths, bert_encoder_out): "\n Args:\n src_tokens (LongTensor): tokens in the source language of shape\n `(batch, src_len)`\n src_lengths (torch.LongTensor): lengths of each source sentence of\n shape `(batch)`\n\n ...
def encodeMLM(self, src_tokens, src_lengths, bert_encoder_out): "\n Args:\n src_tokens (LongTensor): tokens in the source language of shape\n `(batch, src_len)`\n src_lengths (torch.LongTensor): lengths of each source sentence of\n shape `(batch)`\n\n ...
-6,241,553,142,829,516,000
Args: src_tokens (LongTensor): tokens in the source language of shape `(batch, src_len)` src_lengths (torch.LongTensor): lengths of each source sentence of shape `(batch)` Returns: dict: - **encoder_out** (Tensor): the last encoder layer's output of shape `(src_len, batch,...
models/transformer.py
encodeMLM
NCTUMLlab/Adversarial-Masking-Transformers-for-Language-Understanding
python
def encodeMLM(self, src_tokens, src_lengths, bert_encoder_out): "\n Args:\n src_tokens (LongTensor): tokens in the source language of shape\n `(batch, src_len)`\n src_lengths (torch.LongTensor): lengths of each source sentence of\n shape `(batch)`\n\n ...
def reorder_encoder_out(self, encoder_out, bert_outs, new_order): '\n Reorder encoder output according to *new_order*.\n\n Args:\n encoder_out: output from the ``forward()`` method\n new_order (LongTensor): desired order\n\n Returns:\n *encoder_out* rearranged a...
-4,539,497,251,350,111,000
Reorder encoder output according to *new_order*. Args: encoder_out: output from the ``forward()`` method new_order (LongTensor): desired order Returns: *encoder_out* rearranged according to *new_order*
models/transformer.py
reorder_encoder_out
NCTUMLlab/Adversarial-Masking-Transformers-for-Language-Understanding
python
def reorder_encoder_out(self, encoder_out, bert_outs, new_order): '\n Reorder encoder output according to *new_order*.\n\n Args:\n encoder_out: output from the ``forward()`` method\n new_order (LongTensor): desired order\n\n Returns:\n *encoder_out* rearranged a...
def max_positions(self): 'Maximum input length supported by the encoder.' if (self.embed_positions is None): return self.max_source_positions return min(self.max_source_positions, self.embed_positions.max_positions())
-5,228,954,016,557,509,000
Maximum input length supported by the encoder.
models/transformer.py
max_positions
NCTUMLlab/Adversarial-Masking-Transformers-for-Language-Understanding
python
def max_positions(self): if (self.embed_positions is None): return self.max_source_positions return min(self.max_source_positions, self.embed_positions.max_positions())
def upgrade_state_dict_named(self, state_dict, name): 'Upgrade a (possibly old) state dict for new versions of fairseq.' if isinstance(self.embed_positions, SinusoidalPositionalEmbedding): weights_key = '{}.embed_positions.weights'.format(name) if (weights_key in state_dict): del sta...
6,001,696,072,670,587,000
Upgrade a (possibly old) state dict for new versions of fairseq.
models/transformer.py
upgrade_state_dict_named
NCTUMLlab/Adversarial-Masking-Transformers-for-Language-Understanding
python
def upgrade_state_dict_named(self, state_dict, name): if isinstance(self.embed_positions, SinusoidalPositionalEmbedding): weights_key = '{}.embed_positions.weights'.format(name) if (weights_key in state_dict): del state_dict[weights_key] state_dict['{}.embed_positions._float...
def forward(self, prev_output_tokens, encoder_out=None, bert_encoder_out=None, incremental_state=None, **unused): "\n Args:\n prev_output_tokens (LongTensor): previous decoder outputs of shape\n `(batch, tgt_len)`, for input feeding/teacher forcing\n encoder_out (Tensor, ...
8,584,525,393,747,568,000
Args: prev_output_tokens (LongTensor): previous decoder outputs of shape `(batch, tgt_len)`, for input feeding/teacher forcing encoder_out (Tensor, optional): output from the encoder, used for encoder-side attention incremental_state (dict): dictionary used for storing state during :...
models/transformer.py
forward
NCTUMLlab/Adversarial-Masking-Transformers-for-Language-Understanding
python
def forward(self, prev_output_tokens, encoder_out=None, bert_encoder_out=None, incremental_state=None, **unused): "\n Args:\n prev_output_tokens (LongTensor): previous decoder outputs of shape\n `(batch, tgt_len)`, for input feeding/teacher forcing\n encoder_out (Tensor, ...
def extract_features(self, prev_output_tokens, encoder_out=None, bert_encoder_out=None, incremental_state=None, **unused): "\n Similar to *forward* but only return features.\n\n Returns:\n tuple:\n - the decoder's features of shape `(batch, tgt_len, embed_dim)`\n ...
-1,850,262,369,369,789,400
Similar to *forward* but only return features. Returns: tuple: - the decoder's features of shape `(batch, tgt_len, embed_dim)` - a dictionary with any model-specific outputs
models/transformer.py
extract_features
NCTUMLlab/Adversarial-Masking-Transformers-for-Language-Understanding
python
def extract_features(self, prev_output_tokens, encoder_out=None, bert_encoder_out=None, incremental_state=None, **unused): "\n Similar to *forward* but only return features.\n\n Returns:\n tuple:\n - the decoder's features of shape `(batch, tgt_len, embed_dim)`\n ...
def output_layer(self, features, **kwargs): 'Project features to the vocabulary size.' if (self.adaptive_softmax is None): if self.share_input_output_embed: return F.linear(features, self.embed_tokens.weight) else: return F.linear(features, self.embed_out) else: ...
-3,345,116,721,218,766,300
Project features to the vocabulary size.
models/transformer.py
output_layer
NCTUMLlab/Adversarial-Masking-Transformers-for-Language-Understanding
python
def output_layer(self, features, **kwargs): if (self.adaptive_softmax is None): if self.share_input_output_embed: return F.linear(features, self.embed_tokens.weight) else: return F.linear(features, self.embed_out) else: return features
def max_positions(self): 'Maximum output length supported by the decoder.' if (self.embed_positions is None): return self.max_target_positions return min(self.max_target_positions, self.embed_positions.max_positions())
-778,445,331,605,681,300
Maximum output length supported by the decoder.
models/transformer.py
max_positions
NCTUMLlab/Adversarial-Masking-Transformers-for-Language-Understanding
python
def max_positions(self): if (self.embed_positions is None): return self.max_target_positions return min(self.max_target_positions, self.embed_positions.max_positions())
def upgrade_state_dict_named(self, state_dict, name): 'Upgrade a (possibly old) state dict for new versions of fairseq.' if isinstance(self.embed_positions, SinusoidalPositionalEmbedding): weights_key = '{}.embed_positions.weights'.format(name) if (weights_key in state_dict): del sta...
-8,691,086,455,940,025,000
Upgrade a (possibly old) state dict for new versions of fairseq.
models/transformer.py
upgrade_state_dict_named
NCTUMLlab/Adversarial-Masking-Transformers-for-Language-Understanding
python
def upgrade_state_dict_named(self, state_dict, name): if isinstance(self.embed_positions, SinusoidalPositionalEmbedding): weights_key = '{}.embed_positions.weights'.format(name) if (weights_key in state_dict): del state_dict[weights_key] state_dict['{}.embed_positions._float...
def forward(self, prev_output_tokens, encoder_out=None, bert_encoder_out=None, incremental_state=None, **unused): "\n Args:\n prev_output_tokens (LongTensor): previous decoder outputs of shape\n `(batch, tgt_len)`, for input feeding/teacher forcing\n encoder_out (Tensor, ...
8,584,525,393,747,568,000
Args: prev_output_tokens (LongTensor): previous decoder outputs of shape `(batch, tgt_len)`, for input feeding/teacher forcing encoder_out (Tensor, optional): output from the encoder, used for encoder-side attention incremental_state (dict): dictionary used for storing state during :...
models/transformer.py
forward
NCTUMLlab/Adversarial-Masking-Transformers-for-Language-Understanding
python
def forward(self, prev_output_tokens, encoder_out=None, bert_encoder_out=None, incremental_state=None, **unused): "\n Args:\n prev_output_tokens (LongTensor): previous decoder outputs of shape\n `(batch, tgt_len)`, for input feeding/teacher forcing\n encoder_out (Tensor, ...
def extract_features(self, prev_output_tokens, encoder_out=None, bert_encoder_out=None, incremental_state=None, **unused): "\n Similar to *forward* but only return features.\n\n Returns:\n tuple:\n - the decoder's features of shape `(batch, tgt_len, embed_dim)`\n ...
-1,850,262,369,369,789,400
Similar to *forward* but only return features. Returns: tuple: - the decoder's features of shape `(batch, tgt_len, embed_dim)` - a dictionary with any model-specific outputs
models/transformer.py
extract_features
NCTUMLlab/Adversarial-Masking-Transformers-for-Language-Understanding
python
def extract_features(self, prev_output_tokens, encoder_out=None, bert_encoder_out=None, incremental_state=None, **unused): "\n Similar to *forward* but only return features.\n\n Returns:\n tuple:\n - the decoder's features of shape `(batch, tgt_len, embed_dim)`\n ...
def output_layer(self, features, **kwargs): 'Project features to the vocabulary size.' if (self.adaptive_softmax is None): if self.share_input_output_embed: return F.linear(features, self.embed_tokens.weight) else: return F.linear(features, self.embed_out) else: ...
-3,345,116,721,218,766,300
Project features to the vocabulary size.
models/transformer.py
output_layer
NCTUMLlab/Adversarial-Masking-Transformers-for-Language-Understanding
python
def output_layer(self, features, **kwargs): if (self.adaptive_softmax is None): if self.share_input_output_embed: return F.linear(features, self.embed_tokens.weight) else: return F.linear(features, self.embed_out) else: return features
def max_positions(self): 'Maximum output length supported by the decoder.' if (self.embed_positions is None): return self.max_target_positions return min(self.max_target_positions, self.embed_positions.max_positions())
-778,445,331,605,681,300
Maximum output length supported by the decoder.
models/transformer.py
max_positions
NCTUMLlab/Adversarial-Masking-Transformers-for-Language-Understanding
python
def max_positions(self): if (self.embed_positions is None): return self.max_target_positions return min(self.max_target_positions, self.embed_positions.max_positions())
def upgrade_state_dict_named(self, state_dict, name): 'Upgrade a (possibly old) state dict for new versions of fairseq.' if isinstance(self.embed_positions, SinusoidalPositionalEmbedding): weights_key = '{}.embed_positions.weights'.format(name) if (weights_key in state_dict): del sta...
-8,691,086,455,940,025,000
Upgrade a (possibly old) state dict for new versions of fairseq.
models/transformer.py
upgrade_state_dict_named
NCTUMLlab/Adversarial-Masking-Transformers-for-Language-Understanding
python
def upgrade_state_dict_named(self, state_dict, name): if isinstance(self.embed_positions, SinusoidalPositionalEmbedding): weights_key = '{}.embed_positions.weights'.format(name) if (weights_key in state_dict): del state_dict[weights_key] state_dict['{}.embed_positions._float...
def upgrade_state_dict_named(self, state_dict, name): '\n Rename layer norm states from `...layer_norms.0.weight` to\n `...self_attn_layer_norm.weight` and `...layer_norms.1.weight` to\n `...final_layer_norm.weight`\n ' layer_norm_map = {'0': 'self_attn_layer_norm', '1': 'final_layer...
-3,313,760,067,142,762,500
Rename layer norm states from `...layer_norms.0.weight` to `...self_attn_layer_norm.weight` and `...layer_norms.1.weight` to `...final_layer_norm.weight`
models/transformer.py
upgrade_state_dict_named
NCTUMLlab/Adversarial-Masking-Transformers-for-Language-Understanding
python
def upgrade_state_dict_named(self, state_dict, name): '\n Rename layer norm states from `...layer_norms.0.weight` to\n `...self_attn_layer_norm.weight` and `...layer_norms.1.weight` to\n `...final_layer_norm.weight`\n ' layer_norm_map = {'0': 'self_attn_layer_norm', '1': 'final_layer...
def forward(self, x, encoder_padding_mask): '\n Args:\n x (Tensor): input to the layer of shape `(seq_len, batch, embed_dim)`\n encoder_padding_mask (ByteTensor): binary ByteTensor of shape\n `(batch, src_len)` where padding elements are indicated by ``1``.\n\n Ret...
-4,786,362,497,684,975,000
Args: x (Tensor): input to the layer of shape `(seq_len, batch, embed_dim)` encoder_padding_mask (ByteTensor): binary ByteTensor of shape `(batch, src_len)` where padding elements are indicated by ``1``. Returns: encoded output of shape `(batch, src_len, embed_dim)`
models/transformer.py
forward
NCTUMLlab/Adversarial-Masking-Transformers-for-Language-Understanding
python
def forward(self, x, encoder_padding_mask): '\n Args:\n x (Tensor): input to the layer of shape `(seq_len, batch, embed_dim)`\n encoder_padding_mask (ByteTensor): binary ByteTensor of shape\n `(batch, src_len)` where padding elements are indicated by ``1``.\n\n Ret...
def upgrade_state_dict_named(self, state_dict, name): '\n Rename layer norm states from `...layer_norms.0.weight` to\n `...self_attn_layer_norm.weight` and `...layer_norms.1.weight` to\n `...final_layer_norm.weight`\n ' layer_norm_map = {'0': 'self_attn_layer_norm', '1': 'final_layer...
-3,313,760,067,142,762,500
Rename layer norm states from `...layer_norms.0.weight` to `...self_attn_layer_norm.weight` and `...layer_norms.1.weight` to `...final_layer_norm.weight`
models/transformer.py
upgrade_state_dict_named
NCTUMLlab/Adversarial-Masking-Transformers-for-Language-Understanding
python
def upgrade_state_dict_named(self, state_dict, name): '\n Rename layer norm states from `...layer_norms.0.weight` to\n `...self_attn_layer_norm.weight` and `...layer_norms.1.weight` to\n `...final_layer_norm.weight`\n ' layer_norm_map = {'0': 'self_attn_layer_norm', '1': 'final_layer...
def forward(self, x, encoder_padding_mask, bert_encoder_out, bert_encoder_padding_mask): '\n Args:\n x (Tensor): input to the layer of shape `(seq_len, batch, embed_dim)`\n encoder_padding_mask (ByteTensor): binary ByteTensor of shape\n `(batch, src_len)` where padding el...
-6,319,351,232,305,081,000
Args: x (Tensor): input to the layer of shape `(seq_len, batch, embed_dim)` encoder_padding_mask (ByteTensor): binary ByteTensor of shape `(batch, src_len)` where padding elements are indicated by ``1``. Returns: encoded output of shape `(batch, src_len, embed_dim)`
models/transformer.py
forward
NCTUMLlab/Adversarial-Masking-Transformers-for-Language-Understanding
python
def forward(self, x, encoder_padding_mask, bert_encoder_out, bert_encoder_padding_mask): '\n Args:\n x (Tensor): input to the layer of shape `(seq_len, batch, embed_dim)`\n encoder_padding_mask (ByteTensor): binary ByteTensor of shape\n `(batch, src_len)` where padding el...
def forward(self, x, encoder_out=None, encoder_padding_mask=None, bert_encoder_out=None, bert_encoder_padding_mask=None, incremental_state=None, prev_self_attn_state=None, prev_attn_state=None, self_attn_mask=None, self_attn_padding_mask=None): '\n Args:\n x (Tensor): input to the layer of shape `...
4,665,933,914,785,590,000
Args: x (Tensor): input to the layer of shape `(seq_len, batch, embed_dim)` encoder_padding_mask (ByteTensor): binary ByteTensor of shape `(batch, src_len)` where padding elements are indicated by ``1``. Returns: encoded output of shape `(batch, src_len, embed_dim)`
models/transformer.py
forward
NCTUMLlab/Adversarial-Masking-Transformers-for-Language-Understanding
python
def forward(self, x, encoder_out=None, encoder_padding_mask=None, bert_encoder_out=None, bert_encoder_padding_mask=None, incremental_state=None, prev_self_attn_state=None, prev_attn_state=None, self_attn_mask=None, self_attn_padding_mask=None): '\n Args:\n x (Tensor): input to the layer of shape `...
def forward(self, x, encoder_out=None, encoder_padding_mask=None, bert_encoder_out=None, bert_encoder_padding_mask=None, incremental_state=None, prev_self_attn_state=None, prev_attn_state=None, self_attn_mask=None, self_attn_padding_mask=None): '\n Args:\n x (Tensor): input to the layer of shape `...
-4,948,189,932,445,657,000
Args: x (Tensor): input to the layer of shape `(seq_len, batch, embed_dim)` encoder_padding_mask (ByteTensor): binary ByteTensor of shape `(batch, src_len)` where padding elements are indicated by ``1``. Returns: encoded output of shape `(batch, src_len, embed_dim)`
models/transformer.py
forward
NCTUMLlab/Adversarial-Masking-Transformers-for-Language-Understanding
python
def forward(self, x, encoder_out=None, encoder_padding_mask=None, bert_encoder_out=None, bert_encoder_padding_mask=None, incremental_state=None, prev_self_attn_state=None, prev_attn_state=None, self_attn_mask=None, self_attn_padding_mask=None): '\n Args:\n x (Tensor): input to the layer of shape `...
def forward(self, x, encoder_out=None, encoder_padding_mask=None, bert_encoder_out=None, bert_encoder_padding_mask=None, incremental_state=None, prev_self_attn_state=None, prev_attn_state=None, self_attn_mask=None, self_attn_padding_mask=None): '\n Args:\n x (Tensor): input to the layer of shape `...
4,853,743,620,221,757,000
Args: x (Tensor): input to the layer of shape `(seq_len, batch, embed_dim)` encoder_padding_mask (ByteTensor): binary ByteTensor of shape `(batch, src_len)` where padding elements are indicated by ``1``. Returns: encoded output of shape `(batch, src_len, embed_dim)`
models/transformer.py
forward
NCTUMLlab/Adversarial-Masking-Transformers-for-Language-Understanding
python
def forward(self, x, encoder_out=None, encoder_padding_mask=None, bert_encoder_out=None, bert_encoder_padding_mask=None, incremental_state=None, prev_self_attn_state=None, prev_attn_state=None, self_attn_mask=None, self_attn_padding_mask=None): '\n Args:\n x (Tensor): input to the layer of shape `...
def __init__(self, graph, session, y, x, tmp_ckpt_path='/tmp/guided_backprop_ckpt'): 'Constructs a GuidedBackprop SaliencyMask.' super(GuidedBackprop, self).__init__(graph, session, y, x) self.x = x if (GuidedBackprop.GuidedReluRegistered is False): @tf.RegisterGradient('GuidedRelu') de...
7,949,305,015,942,975,000
Constructs a GuidedBackprop SaliencyMask.
saliency/guided_backprop.py
__init__
aliabd/history-of-interpretation
python
def __init__(self, graph, session, y, x, tmp_ckpt_path='/tmp/guided_backprop_ckpt'): super(GuidedBackprop, self).__init__(graph, session, y, x) self.x = x if (GuidedBackprop.GuidedReluRegistered is False): @tf.RegisterGradient('GuidedRelu') def _GuidedReluGrad(op, grad): ga...
def GetMask(self, x_value, feed_dict={}): 'Returns a GuidedBackprop mask.' with self.guided_graph.as_default(): guided_feed_dict = {} for tensor in feed_dict: guided_feed_dict[tensor.name] = feed_dict[tensor] guided_feed_dict[self.x.name] = [x_value] return self.guided_se...
1,790,101,936,076,309,000
Returns a GuidedBackprop mask.
saliency/guided_backprop.py
GetMask
aliabd/history-of-interpretation
python
def GetMask(self, x_value, feed_dict={}): with self.guided_graph.as_default(): guided_feed_dict = {} for tensor in feed_dict: guided_feed_dict[tensor.name] = feed_dict[tensor] guided_feed_dict[self.x.name] = [x_value] return self.guided_sess.run(self.guided_grads_node, f...
def validate_url(url): '\n Auxiliary method to validate an urllib\n :param url: An url to be validated\n :type url: string\n :returns: True if the url is valid\n :rtype: bool\n ' scheme = url.split('://')[0].lower() if (scheme not in url_schemes): return False if (not bool(url_...
2,019,927,503,990,452,000
Auxiliary method to validate an urllib :param url: An url to be validated :type url: string :returns: True if the url is valid :rtype: bool
app/utils/onelogin/saml2/settings.py
validate_url
nycrecords/intranet
python
def validate_url(url): '\n Auxiliary method to validate an urllib\n :param url: An url to be validated\n :type url: string\n :returns: True if the url is valid\n :rtype: bool\n ' scheme = url.split('://')[0].lower() if (scheme not in url_schemes): return False if (not bool(url_...
def __init__(self, settings=None, custom_base_path=None, sp_validation_only=False): '\n Initializes the settings:\n - Sets the paths of the different folders\n - Loads settings info from settings file or array/object provided\n\n :param settings: SAML Toolkit Settings\n :type sett...
-4,102,128,884,988,414,500
Initializes the settings: - Sets the paths of the different folders - Loads settings info from settings file or array/object provided :param settings: SAML Toolkit Settings :type settings: dict :param custom_base_path: Path where are stored the settings file and the cert folder :type custom_base_path: string :param ...
app/utils/onelogin/saml2/settings.py
__init__
nycrecords/intranet
python
def __init__(self, settings=None, custom_base_path=None, sp_validation_only=False): '\n Initializes the settings:\n - Sets the paths of the different folders\n - Loads settings info from settings file or array/object provided\n\n :param settings: SAML Toolkit Settings\n :type sett...
def __load_paths(self, base_path=None): '\n Set the paths of the different folders\n ' if (base_path is None): base_path = dirname(dirname(dirname(__file__))) if (not base_path.endswith(sep)): base_path += sep self.__paths = {'base': base_path, 'cert': ((base_path + 'certs'...
-7,425,753,098,019,775,000
Set the paths of the different folders
app/utils/onelogin/saml2/settings.py
__load_paths
nycrecords/intranet
python
def __load_paths(self, base_path=None): '\n \n ' if (base_path is None): base_path = dirname(dirname(dirname(__file__))) if (not base_path.endswith(sep)): base_path += sep self.__paths = {'base': base_path, 'cert': ((base_path + 'certs') + sep), 'lib': ((base_path + 'lib') ...
def __update_paths(self, settings): '\n Set custom paths if necessary\n ' if (not isinstance(settings, dict)): return if ('custom_base_path' in settings): base_path = settings['custom_base_path'] base_path = join(dirname(__file__), base_path) self.__load_paths(b...
-851,702,267,590,710,300
Set custom paths if necessary
app/utils/onelogin/saml2/settings.py
__update_paths
nycrecords/intranet
python
def __update_paths(self, settings): '\n \n ' if (not isinstance(settings, dict)): return if ('custom_base_path' in settings): base_path = settings['custom_base_path'] base_path = join(dirname(__file__), base_path) self.__load_paths(base_path)
def get_base_path(self): '\n Returns base path\n\n :return: The base toolkit folder path\n :rtype: string\n ' return self.__paths['base']
-3,251,405,120,382,975,500
Returns base path :return: The base toolkit folder path :rtype: string
app/utils/onelogin/saml2/settings.py
get_base_path
nycrecords/intranet
python
def get_base_path(self): '\n Returns base path\n\n :return: The base toolkit folder path\n :rtype: string\n ' return self.__paths['base']
def get_cert_path(self): '\n Returns cert path\n\n :return: The cert folder path\n :rtype: string\n ' return self.__paths['cert']
-2,868,438,709,607,504,400
Returns cert path :return: The cert folder path :rtype: string
app/utils/onelogin/saml2/settings.py
get_cert_path
nycrecords/intranet
python
def get_cert_path(self): '\n Returns cert path\n\n :return: The cert folder path\n :rtype: string\n ' return self.__paths['cert']
def get_lib_path(self): '\n Returns lib path\n\n :return: The library folder path\n :rtype: string\n ' return self.__paths['lib']
-3,343,954,377,221,302,300
Returns lib path :return: The library folder path :rtype: string
app/utils/onelogin/saml2/settings.py
get_lib_path
nycrecords/intranet
python
def get_lib_path(self): '\n Returns lib path\n\n :return: The library folder path\n :rtype: string\n ' return self.__paths['lib']
def get_ext_lib_path(self): '\n Returns external lib path\n\n :return: The external library folder path\n :rtype: string\n ' return self.__paths['extlib']
-7,216,888,168,113,255,000
Returns external lib path :return: The external library folder path :rtype: string
app/utils/onelogin/saml2/settings.py
get_ext_lib_path
nycrecords/intranet
python
def get_ext_lib_path(self): '\n Returns external lib path\n\n :return: The external library folder path\n :rtype: string\n ' return self.__paths['extlib']
def get_schemas_path(self): '\n Returns schema path\n\n :return: The schema folder path\n :rtype: string\n ' return (self.__paths['lib'] + 'schemas/')
-4,632,891,345,904,846,000
Returns schema path :return: The schema folder path :rtype: string
app/utils/onelogin/saml2/settings.py
get_schemas_path
nycrecords/intranet
python
def get_schemas_path(self): '\n Returns schema path\n\n :return: The schema folder path\n :rtype: string\n ' return (self.__paths['lib'] + 'schemas/')
def __load_settings_from_dict(self, settings): '\n Loads settings info from a settings Dict\n\n :param settings: SAML Toolkit Settings\n :type settings: dict\n\n :returns: True if the settings info is valid\n :rtype: boolean\n ' errors = self.check_settings(settings) ...
9,101,060,825,214,802,000
Loads settings info from a settings Dict :param settings: SAML Toolkit Settings :type settings: dict :returns: True if the settings info is valid :rtype: boolean
app/utils/onelogin/saml2/settings.py
__load_settings_from_dict
nycrecords/intranet
python
def __load_settings_from_dict(self, settings): '\n Loads settings info from a settings Dict\n\n :param settings: SAML Toolkit Settings\n :type settings: dict\n\n :returns: True if the settings info is valid\n :rtype: boolean\n ' errors = self.check_settings(settings) ...
def __load_settings_from_file(self): '\n Loads settings info from the settings json file\n\n :returns: True if the settings info is valid\n :rtype: boolean\n ' filename = (self.get_base_path() + 'settings.json') if (not exists(filename)): raise OneLogin_Saml2_Error('Setti...
3,696,009,825,667,300,400
Loads settings info from the settings json file :returns: True if the settings info is valid :rtype: boolean
app/utils/onelogin/saml2/settings.py
__load_settings_from_file
nycrecords/intranet
python
def __load_settings_from_file(self): '\n Loads settings info from the settings json file\n\n :returns: True if the settings info is valid\n :rtype: boolean\n ' filename = (self.get_base_path() + 'settings.json') if (not exists(filename)): raise OneLogin_Saml2_Error('Setti...
def __add_default_values(self): '\n Add default values if the settings info is not complete\n ' self.__sp.setdefault('assertionConsumerService', {}) self.__sp['assertionConsumerService'].setdefault('binding', OneLogin_Saml2_Constants.BINDING_HTTP_POST) self.__sp.setdefault('attributeConsum...
8,789,121,310,913,046,000
Add default values if the settings info is not complete
app/utils/onelogin/saml2/settings.py
__add_default_values
nycrecords/intranet
python
def __add_default_values(self): '\n \n ' self.__sp.setdefault('assertionConsumerService', {}) self.__sp['assertionConsumerService'].setdefault('binding', OneLogin_Saml2_Constants.BINDING_HTTP_POST) self.__sp.setdefault('attributeConsumingService', {}) self.__sp.setdefault('singleLogout...
def check_settings(self, settings): '\n Checks the settings info.\n\n :param settings: Dict with settings data\n :type settings: dict\n\n :returns: Errors found on the settings data\n :rtype: list\n ' assert isinstance(settings, dict) errors = [] if ((not isinst...
6,683,541,287,288,272,000
Checks the settings info. :param settings: Dict with settings data :type settings: dict :returns: Errors found on the settings data :rtype: list
app/utils/onelogin/saml2/settings.py
check_settings
nycrecords/intranet
python
def check_settings(self, settings): '\n Checks the settings info.\n\n :param settings: Dict with settings data\n :type settings: dict\n\n :returns: Errors found on the settings data\n :rtype: list\n ' assert isinstance(settings, dict) errors = [] if ((not isinst...
def check_idp_settings(self, settings): '\n Checks the IdP settings info.\n :param settings: Dict with settings data\n :type settings: dict\n :returns: Errors found on the IdP settings data\n :rtype: list\n ' assert isinstance(settings, dict) errors = [] if ((no...
8,715,893,815,939,197,000
Checks the IdP settings info. :param settings: Dict with settings data :type settings: dict :returns: Errors found on the IdP settings data :rtype: list
app/utils/onelogin/saml2/settings.py
check_idp_settings
nycrecords/intranet
python
def check_idp_settings(self, settings): '\n Checks the IdP settings info.\n :param settings: Dict with settings data\n :type settings: dict\n :returns: Errors found on the IdP settings data\n :rtype: list\n ' assert isinstance(settings, dict) errors = [] if ((no...
def check_sp_settings(self, settings): '\n Checks the SP settings info.\n :param settings: Dict with settings data\n :type settings: dict\n :returns: Errors found on the SP settings data\n :rtype: list\n ' assert isinstance(settings, dict) errors = [] if ((not i...
-2,496,403,301,086,345,700
Checks the SP settings info. :param settings: Dict with settings data :type settings: dict :returns: Errors found on the SP settings data :rtype: list
app/utils/onelogin/saml2/settings.py
check_sp_settings
nycrecords/intranet
python
def check_sp_settings(self, settings): '\n Checks the SP settings info.\n :param settings: Dict with settings data\n :type settings: dict\n :returns: Errors found on the SP settings data\n :rtype: list\n ' assert isinstance(settings, dict) errors = [] if ((not i...
def check_sp_certs(self): '\n Checks if the x509 certs of the SP exists and are valid.\n :returns: If the x509 certs of the SP exists and are valid\n :rtype: boolean\n ' key = self.get_sp_key() cert = self.get_sp_cert() return ((key is not None) and (cert is not None))
-7,812,650,226,965,906,000
Checks if the x509 certs of the SP exists and are valid. :returns: If the x509 certs of the SP exists and are valid :rtype: boolean
app/utils/onelogin/saml2/settings.py
check_sp_certs
nycrecords/intranet
python
def check_sp_certs(self): '\n Checks if the x509 certs of the SP exists and are valid.\n :returns: If the x509 certs of the SP exists and are valid\n :rtype: boolean\n ' key = self.get_sp_key() cert = self.get_sp_cert() return ((key is not None) and (cert is not None))
def get_sp_key(self): '\n Returns the x509 private key of the SP.\n :returns: SP private key\n :rtype: string or None\n ' key = self.__sp.get('privateKey') key_file_name = (self.__paths['cert'] + 'sp.key') if ((not key) and exists(key_file_name)): with open(key_file_n...
-4,037,297,485,836,650,000
Returns the x509 private key of the SP. :returns: SP private key :rtype: string or None
app/utils/onelogin/saml2/settings.py
get_sp_key
nycrecords/intranet
python
def get_sp_key(self): '\n Returns the x509 private key of the SP.\n :returns: SP private key\n :rtype: string or None\n ' key = self.__sp.get('privateKey') key_file_name = (self.__paths['cert'] + 'sp.key') if ((not key) and exists(key_file_name)): with open(key_file_n...
def get_sp_cert(self): '\n Returns the x509 public cert of the SP.\n :returns: SP public cert\n :rtype: string or None\n ' cert = self.__sp.get('x509cert') cert_file_name = (self.__paths['cert'] + 'sp.crt') if ((not cert) and exists(cert_file_name)): with open(cert_fi...
3,085,101,086,525,962,000
Returns the x509 public cert of the SP. :returns: SP public cert :rtype: string or None
app/utils/onelogin/saml2/settings.py
get_sp_cert
nycrecords/intranet
python
def get_sp_cert(self): '\n Returns the x509 public cert of the SP.\n :returns: SP public cert\n :rtype: string or None\n ' cert = self.__sp.get('x509cert') cert_file_name = (self.__paths['cert'] + 'sp.crt') if ((not cert) and exists(cert_file_name)): with open(cert_fi...
def get_sp_cert_new(self): '\n Returns the x509 public of the SP planned\n to be used soon instead the other public cert\n :returns: SP public cert new\n :rtype: string or None\n ' cert = self.__sp.get('x509certNew') cert_file_name = (self.__paths['cert'] + 'sp_new.crt') ...
-1,498,846,491,623,402,500
Returns the x509 public of the SP planned to be used soon instead the other public cert :returns: SP public cert new :rtype: string or None
app/utils/onelogin/saml2/settings.py
get_sp_cert_new
nycrecords/intranet
python
def get_sp_cert_new(self): '\n Returns the x509 public of the SP planned\n to be used soon instead the other public cert\n :returns: SP public cert new\n :rtype: string or None\n ' cert = self.__sp.get('x509certNew') cert_file_name = (self.__paths['cert'] + 'sp_new.crt') ...
def get_idp_cert(self): '\n Returns the x509 public cert of the IdP.\n :returns: IdP public cert\n :rtype: string\n ' return self.__idp.get('x509cert')
4,088,177,130,043,971,000
Returns the x509 public cert of the IdP. :returns: IdP public cert :rtype: string
app/utils/onelogin/saml2/settings.py
get_idp_cert
nycrecords/intranet
python
def get_idp_cert(self): '\n Returns the x509 public cert of the IdP.\n :returns: IdP public cert\n :rtype: string\n ' return self.__idp.get('x509cert')
def get_idp_data(self): '\n Gets the IdP data.\n\n :returns: IdP info\n :rtype: dict\n ' return self.__idp
-3,116,901,750,163,315,000
Gets the IdP data. :returns: IdP info :rtype: dict
app/utils/onelogin/saml2/settings.py
get_idp_data
nycrecords/intranet
python
def get_idp_data(self): '\n Gets the IdP data.\n\n :returns: IdP info\n :rtype: dict\n ' return self.__idp
def get_sp_data(self): '\n Gets the SP data.\n\n :returns: SP info\n :rtype: dict\n ' return self.__sp
-7,802,741,565,788,101,000
Gets the SP data. :returns: SP info :rtype: dict
app/utils/onelogin/saml2/settings.py
get_sp_data
nycrecords/intranet
python
def get_sp_data(self): '\n Gets the SP data.\n\n :returns: SP info\n :rtype: dict\n ' return self.__sp
def get_security_data(self): '\n Gets security data.\n\n :returns: Security info\n :rtype: dict\n ' return self.__security
1,365,572,923,322,081,000
Gets security data. :returns: Security info :rtype: dict
app/utils/onelogin/saml2/settings.py
get_security_data
nycrecords/intranet
python
def get_security_data(self): '\n Gets security data.\n\n :returns: Security info\n :rtype: dict\n ' return self.__security
def get_contacts(self): '\n Gets contact data.\n\n :returns: Contacts info\n :rtype: dict\n ' return self.__contacts
-8,828,376,608,204,893,000
Gets contact data. :returns: Contacts info :rtype: dict
app/utils/onelogin/saml2/settings.py
get_contacts
nycrecords/intranet
python
def get_contacts(self): '\n Gets contact data.\n\n :returns: Contacts info\n :rtype: dict\n ' return self.__contacts
def get_organization(self): '\n Gets organization data.\n\n :returns: Organization info\n :rtype: dict\n ' return self.__organization
7,596,810,709,364,819,000
Gets organization data. :returns: Organization info :rtype: dict
app/utils/onelogin/saml2/settings.py
get_organization
nycrecords/intranet
python
def get_organization(self): '\n Gets organization data.\n\n :returns: Organization info\n :rtype: dict\n ' return self.__organization
def get_sp_metadata(self): '\n Gets the SP metadata. The XML representation.\n :returns: SP metadata (xml)\n :rtype: string\n ' metadata = OneLogin_Saml2_Metadata.builder(self.__sp, self.__security['authnRequestsSigned'], self.__security['wantAssertionsSigned'], self.__security['meta...
-4,473,593,141,927,607,300
Gets the SP metadata. The XML representation. :returns: SP metadata (xml) :rtype: string
app/utils/onelogin/saml2/settings.py
get_sp_metadata
nycrecords/intranet
python
def get_sp_metadata(self): '\n Gets the SP metadata. The XML representation.\n :returns: SP metadata (xml)\n :rtype: string\n ' metadata = OneLogin_Saml2_Metadata.builder(self.__sp, self.__security['authnRequestsSigned'], self.__security['wantAssertionsSigned'], self.__security['meta...
def validate_metadata(self, xml): "\n Validates an XML SP Metadata.\n\n :param xml: Metadata's XML that will be validate\n :type xml: string\n\n :returns: The list of found errors\n :rtype: list\n " assert isinstance(xml, compat.text_types) if (len(xml) == 0): ...
3,210,722,307,556,125,000
Validates an XML SP Metadata. :param xml: Metadata's XML that will be validate :type xml: string :returns: The list of found errors :rtype: list
app/utils/onelogin/saml2/settings.py
validate_metadata
nycrecords/intranet
python
def validate_metadata(self, xml): "\n Validates an XML SP Metadata.\n\n :param xml: Metadata's XML that will be validate\n :type xml: string\n\n :returns: The list of found errors\n :rtype: list\n " assert isinstance(xml, compat.text_types) if (len(xml) == 0): ...
def format_idp_cert(self): '\n Formats the IdP cert.\n ' self.__idp['x509cert'] = OneLogin_Saml2_Utils.format_cert(self.__idp['x509cert'])
154,846,901,795,047,100
Formats the IdP cert.
app/utils/onelogin/saml2/settings.py
format_idp_cert
nycrecords/intranet
python
def format_idp_cert(self): '\n \n ' self.__idp['x509cert'] = OneLogin_Saml2_Utils.format_cert(self.__idp['x509cert'])
def format_idp_cert_multi(self): '\n Formats the Multple IdP certs.\n ' if ('x509certMulti' in self.__idp): if ('signing' in self.__idp['x509certMulti']): for idx in range(len(self.__idp['x509certMulti']['signing'])): self.__idp['x509certMulti']['signing'][idx] ...
-5,308,441,926,965,280,000
Formats the Multple IdP certs.
app/utils/onelogin/saml2/settings.py
format_idp_cert_multi
nycrecords/intranet
python
def format_idp_cert_multi(self): '\n \n ' if ('x509certMulti' in self.__idp): if ('signing' in self.__idp['x509certMulti']): for idx in range(len(self.__idp['x509certMulti']['signing'])): self.__idp['x509certMulti']['signing'][idx] = OneLogin_Saml2_Utils.format_...
def format_sp_cert(self): '\n Formats the SP cert.\n ' self.__sp['x509cert'] = OneLogin_Saml2_Utils.format_cert(self.__sp['x509cert'])
-8,799,753,653,561,585,000
Formats the SP cert.
app/utils/onelogin/saml2/settings.py
format_sp_cert
nycrecords/intranet
python
def format_sp_cert(self): '\n \n ' self.__sp['x509cert'] = OneLogin_Saml2_Utils.format_cert(self.__sp['x509cert'])
def format_sp_cert_new(self): '\n Formats the SP cert.\n ' self.__sp['x509certNew'] = OneLogin_Saml2_Utils.format_cert(self.__sp['x509certNew'])
-4,849,810,101,938,704,000
Formats the SP cert.
app/utils/onelogin/saml2/settings.py
format_sp_cert_new
nycrecords/intranet
python
def format_sp_cert_new(self): '\n \n ' self.__sp['x509certNew'] = OneLogin_Saml2_Utils.format_cert(self.__sp['x509certNew'])
def format_sp_key(self): '\n Formats the private key.\n ' self.__sp['privateKey'] = OneLogin_Saml2_Utils.format_private_key(self.__sp['privateKey'])
240,490,718,022,734,240
Formats the private key.
app/utils/onelogin/saml2/settings.py
format_sp_key
nycrecords/intranet
python
def format_sp_key(self): '\n \n ' self.__sp['privateKey'] = OneLogin_Saml2_Utils.format_private_key(self.__sp['privateKey'])
def get_errors(self): '\n Returns an array with the errors, the array is empty when the settings is ok.\n\n :returns: Errors\n :rtype: list\n ' return self.__errors
-450,769,031,362,331,000
Returns an array with the errors, the array is empty when the settings is ok. :returns: Errors :rtype: list
app/utils/onelogin/saml2/settings.py
get_errors
nycrecords/intranet
python
def get_errors(self): '\n Returns an array with the errors, the array is empty when the settings is ok.\n\n :returns: Errors\n :rtype: list\n ' return self.__errors
def set_strict(self, value): '\n Activates or deactivates the strict mode.\n\n :param value: Strict parameter\n :type value: boolean\n ' assert isinstance(value, bool) self.__strict = value
-1,835,184,990,267,616,000
Activates or deactivates the strict mode. :param value: Strict parameter :type value: boolean
app/utils/onelogin/saml2/settings.py
set_strict
nycrecords/intranet
python
def set_strict(self, value): '\n Activates or deactivates the strict mode.\n\n :param value: Strict parameter\n :type value: boolean\n ' assert isinstance(value, bool) self.__strict = value
def is_strict(self): "\n Returns if the 'strict' mode is active.\n\n :returns: Strict parameter\n :rtype: boolean\n " return self.__strict
-5,834,133,523,043,742,000
Returns if the 'strict' mode is active. :returns: Strict parameter :rtype: boolean
app/utils/onelogin/saml2/settings.py
is_strict
nycrecords/intranet
python
def is_strict(self): "\n Returns if the 'strict' mode is active.\n\n :returns: Strict parameter\n :rtype: boolean\n " return self.__strict
def is_debug_active(self): '\n Returns if the debug is active.\n\n :returns: Debug parameter\n :rtype: boolean\n ' return self.__debug
2,389,600,388,186,807,000
Returns if the debug is active. :returns: Debug parameter :rtype: boolean
app/utils/onelogin/saml2/settings.py
is_debug_active
nycrecords/intranet
python
def is_debug_active(self): '\n Returns if the debug is active.\n\n :returns: Debug parameter\n :rtype: boolean\n ' return self.__debug
@pytest.mark.ui def test_apply_mag_field_view1(exopy_qtbot, root_view, task_workbench): 'Test ApplyMagFieldView widget outisde of a LoopTask.\n\n ' task = ApplyMagFieldTask(name='Test') root_view.task.add_child_task(0, task) show_and_close_widget(exopy_qtbot, ApplyMagFieldView(task=task, root=root_vi...
8,545,179,322,454,801,000
Test ApplyMagFieldView widget outisde of a LoopTask.
tests/tasks/tasks/instr/test_apply_mag_field_task.py
test_apply_mag_field_view1
Qcircuits/exopy_hqc_legacy
python
@pytest.mark.ui def test_apply_mag_field_view1(exopy_qtbot, root_view, task_workbench): '\n\n ' task = ApplyMagFieldTask(name='Test') root_view.task.add_child_task(0, task) show_and_close_widget(exopy_qtbot, ApplyMagFieldView(task=task, root=root_view))
@pytest.mark.ui def test_apply_mag_field_view2(exopy_qtbot, root_view, task_workbench): 'Test ApplyMagFieldView widget inside of a LoopTask.\n\n ' task = ApplyMagFieldTask(name='Test') loop = LoopTask(name='r', task=task) root_view.task.add_child_task(0, loop) show_and_close_widget(exopy_qtbot, L...
4,429,556,137,842,436,600
Test ApplyMagFieldView widget inside of a LoopTask.
tests/tasks/tasks/instr/test_apply_mag_field_task.py
test_apply_mag_field_view2
Qcircuits/exopy_hqc_legacy
python
@pytest.mark.ui def test_apply_mag_field_view2(exopy_qtbot, root_view, task_workbench): '\n\n ' task = ApplyMagFieldTask(name='Test') loop = LoopTask(name='r', task=task) root_view.task.add_child_task(0, loop) show_and_close_widget(exopy_qtbot, LoopView(task=loop, root=root_view))
def test_check1(self): 'Simply test that everything is ok if field can be evaluated.\n\n ' self.task.field = '3.0' (test, traceback) = self.task.check(test_instr=True) assert test assert (not traceback) assert (self.task.get_from_database('Test_field') == 3.0)
3,313,670,270,641,834,000
Simply test that everything is ok if field can be evaluated.
tests/tasks/tasks/instr/test_apply_mag_field_task.py
test_check1
Qcircuits/exopy_hqc_legacy
python
def test_check1(self): '\n\n ' self.task.field = '3.0' (test, traceback) = self.task.check(test_instr=True) assert test assert (not traceback) assert (self.task.get_from_database('Test_field') == 3.0)
def test_check2(self): 'Check handling a wrong field.\n\n ' self.task.field = '*1.0*' (test, traceback) = self.task.check(test_instr=True) assert (not test) assert (len(traceback) == 1) assert ('root/Test-field' in traceback) assert (self.task.get_from_database('Test_field') == 0.01)
7,797,678,657,480,563,000
Check handling a wrong field.
tests/tasks/tasks/instr/test_apply_mag_field_task.py
test_check2
Qcircuits/exopy_hqc_legacy
python
def test_check2(self): '\n\n ' self.task.field = '*1.0*' (test, traceback) = self.task.check(test_instr=True) assert (not test) assert (len(traceback) == 1) assert ('root/Test-field' in traceback) assert (self.task.get_from_database('Test_field') == 0.01)
def test_perform1(self): 'Simple test when everything is right.\n\n ' self.task.field = '2.0' self.root.prepare() self.task.perform() assert (self.root.get_from_database('Test_field') == 2.0)
-9,060,059,394,285,495,000
Simple test when everything is right.
tests/tasks/tasks/instr/test_apply_mag_field_task.py
test_perform1
Qcircuits/exopy_hqc_legacy
python
def test_perform1(self): '\n\n ' self.task.field = '2.0' self.root.prepare() self.task.perform() assert (self.root.get_from_database('Test_field') == 2.0)
def _skip_date_tokens(tokens): '\n Based on RFC 3164 + RFC 5424 and real-world logs\n ' if (tokens and tokens[0].startswith('<')): tokens.pop(0) while (tokens and ((not tokens[0]) or tokens[0][:1].isdigit())): tokens.pop(0)
-6,881,443,272,031,541,000
Based on RFC 3164 + RFC 5424 and real-world logs
syslog.py
_skip_date_tokens
Bun/ha-syslog-devtracker
python
def _skip_date_tokens(tokens): '\n \n ' if (tokens and tokens[0].startswith('<')): tokens.pop(0) while (tokens and ((not tokens[0]) or tokens[0][:1].isdigit())): tokens.pop(0)
def parse_syslog_line(line): 'Parses lines created by hostapd and dnsmasq DHCP' tokens = line.split(' ') _skip_date_tokens(tokens) process = _find_process(tokens) if ((not process) or (not tokens)): _LOGGER.debug('Unable to process line: %r', line) return if (process == 'hostapd'...
-6,569,647,656,581,431,000
Parses lines created by hostapd and dnsmasq DHCP
syslog.py
parse_syslog_line
Bun/ha-syslog-devtracker
python
def parse_syslog_line(line): tokens = line.split(' ') _skip_date_tokens(tokens) process = _find_process(tokens) if ((not process) or (not tokens)): _LOGGER.debug('Unable to process line: %r', line) return if (process == 'hostapd'): if (len(tokens) == 3): if (...
def _add_conv_fc_branch(self, num_branch_convs, num_branch_fcs, in_channels, is_shared=False): 'Add shared or separable branch.\n\n convs -> avg pool (optional) -> fcs\n ' last_layer_dim = in_channels branch_convs = nn.ModuleList() if (num_branch_convs > 0): for i in range(num_bran...
-8,176,502,878,514,245,000
Add shared or separable branch. convs -> avg pool (optional) -> fcs
mmdet/models/roi_heads/bbox_heads/convfc_bbox_head.py
_add_conv_fc_branch
marcovalenti/mmdetection
python
def _add_conv_fc_branch(self, num_branch_convs, num_branch_fcs, in_channels, is_shared=False): 'Add shared or separable branch.\n\n convs -> avg pool (optional) -> fcs\n ' last_layer_dim = in_channels branch_convs = nn.ModuleList() if (num_branch_convs > 0): for i in range(num_bran...
def get_targets(self, sampling_results, gt_bboxes, gt_labels, rcnn_train_cfg, reference_labels, classes, concat=True): "Calculate the ground truth for all samples in a batch according to\n the sampling_results.\n Almost the same as the implementation in bbox_head, we passed\n additional paramet...
-50,011,819,819,159,050
Calculate the ground truth for all samples in a batch according to the sampling_results. Almost the same as the implementation in bbox_head, we passed additional parameters pos_inds_list and neg_inds_list to `_get_target_single` function. Args: sampling_results (List[obj:SamplingResults]): Assign results of ...
mmdet/models/roi_heads/bbox_heads/convfc_bbox_head.py
get_targets
marcovalenti/mmdetection
python
def get_targets(self, sampling_results, gt_bboxes, gt_labels, rcnn_train_cfg, reference_labels, classes, concat=True): "Calculate the ground truth for all samples in a batch according to\n the sampling_results.\n Almost the same as the implementation in bbox_head, we passed\n additional paramet...
def test_publisher_structure(): '\n The module.publisher itself is a bit of a skeleton...\n ' params = {'1': 1, '2': 2, 'channel_name': 'test'} test_publisher = Publisher(params) assert (test_publisher.get_parameters() == {'1': 1, '2': 2, 'channel_name': 'test'}) test_publisher.set_data_block(...
2,516,664,684,722,745,000
The module.publisher itself is a bit of a skeleton...
src/decisionengine/framework/modules/tests/test_Publisher.py
test_publisher_structure
BrunoCoimbra/decisionengine
python
def test_publisher_structure(): '\n \n ' params = {'1': 1, '2': 2, 'channel_name': 'test'} test_publisher = Publisher(params) assert (test_publisher.get_parameters() == {'1': 1, '2': 2, 'channel_name': 'test'}) test_publisher.set_data_block('example') assert (test_publisher.get_data_block(...
def create_dataset_from_tf_record_files(input_file_pattern, pre_batch_size, batch_size, is_training=True): 'Creates dataset from (tf)records files for training/evaluation.' files = tf.data.Dataset.list_files(input_file_pattern, shuffle=is_training) def make_dataset(files_dataset, shard_index): 'Ret...
-4,105,225,009,478,872,600
Creates dataset from (tf)records files for training/evaluation.
examples/benchmark/utils/recommendation/ncf_input_pipeline.py
create_dataset_from_tf_record_files
Ezra-H/autodist
python
def create_dataset_from_tf_record_files(input_file_pattern, pre_batch_size, batch_size, is_training=True): files = tf.data.Dataset.list_files(input_file_pattern, shuffle=is_training) def make_dataset(files_dataset, shard_index): 'Returns dataset for sharded tf record files.' if (pre_batch_...
def create_dataset_from_data_producer(producer, params): 'Return dataset online-generating data.' def preprocess_train_input(features, labels): 'Pre-process the training data.\n\n This is needed because\n - The label needs to be extended to be used in the loss fn\n - We need the sa...
-7,371,762,913,903,107,000
Return dataset online-generating data.
examples/benchmark/utils/recommendation/ncf_input_pipeline.py
create_dataset_from_data_producer
Ezra-H/autodist
python
def create_dataset_from_data_producer(producer, params): def preprocess_train_input(features, labels): 'Pre-process the training data.\n\n This is needed because\n - The label needs to be extended to be used in the loss fn\n - We need the same inputs for training and eval so addin...
def create_ncf_input_data(params, producer=None, input_meta_data=None, strategy=None): 'Creates NCF training/evaluation dataset.\n\n Args:\n params: Dictionary containing parameters for train/evaluation data.\n producer: Instance of BaseDataConstructor that generates data online. Must\n not be N...
-6,474,459,502,976,197,000
Creates NCF training/evaluation dataset. Args: params: Dictionary containing parameters for train/evaluation data. producer: Instance of BaseDataConstructor that generates data online. Must not be None when params['train_dataset_path'] or params['eval_dataset_path'] is not specified. input_meta_data: A d...
examples/benchmark/utils/recommendation/ncf_input_pipeline.py
create_ncf_input_data
Ezra-H/autodist
python
def create_ncf_input_data(params, producer=None, input_meta_data=None, strategy=None): 'Creates NCF training/evaluation dataset.\n\n Args:\n params: Dictionary containing parameters for train/evaluation data.\n producer: Instance of BaseDataConstructor that generates data online. Must\n not be N...
def make_dataset(files_dataset, shard_index): 'Returns dataset for sharded tf record files.' if (pre_batch_size != batch_size): raise ValueError('Pre-batch ({}) size is not equal to batch size ({})'.format(pre_batch_size, batch_size)) files_dataset = files_dataset.shard(NUM_SHARDS, shard_index) ...
-8,816,612,933,234,172,000
Returns dataset for sharded tf record files.
examples/benchmark/utils/recommendation/ncf_input_pipeline.py
make_dataset
Ezra-H/autodist
python
def make_dataset(files_dataset, shard_index): if (pre_batch_size != batch_size): raise ValueError('Pre-batch ({}) size is not equal to batch size ({})'.format(pre_batch_size, batch_size)) files_dataset = files_dataset.shard(NUM_SHARDS, shard_index) dataset = files_dataset.interleave(tf.data.TFR...
def preprocess_train_input(features, labels): 'Pre-process the training data.\n\n This is needed because\n - The label needs to be extended to be used in the loss fn\n - We need the same inputs for training and eval so adding fake inputs\n for DUPLICATE_MASK in training data.\n\n ...
1,766,241,002,850,631,000
Pre-process the training data. This is needed because - The label needs to be extended to be used in the loss fn - We need the same inputs for training and eval so adding fake inputs for DUPLICATE_MASK in training data. Args: features: Dictionary of features for training. labels: Training labels. Returns: Pr...
examples/benchmark/utils/recommendation/ncf_input_pipeline.py
preprocess_train_input
Ezra-H/autodist
python
def preprocess_train_input(features, labels): 'Pre-process the training data.\n\n This is needed because\n - The label needs to be extended to be used in the loss fn\n - We need the same inputs for training and eval so adding fake inputs\n for DUPLICATE_MASK in training data.\n\n ...
def preprocess_eval_input(features): 'Pre-process the eval data.\n\n This is needed because:\n - The label needs to be extended to be used in the loss fn\n - We need the same inputs for training and eval so adding fake inputs\n for VALID_PT_MASK in eval data.\n\n Args:\n ...
5,271,456,008,588,656,000
Pre-process the eval data. This is needed because: - The label needs to be extended to be used in the loss fn - We need the same inputs for training and eval so adding fake inputs for VALID_PT_MASK in eval data. Args: features: Dictionary of features for evaluation. Returns: Processed evaluation features.
examples/benchmark/utils/recommendation/ncf_input_pipeline.py
preprocess_eval_input
Ezra-H/autodist
python
def preprocess_eval_input(features): 'Pre-process the eval data.\n\n This is needed because:\n - The label needs to be extended to be used in the loss fn\n - We need the same inputs for training and eval so adding fake inputs\n for VALID_PT_MASK in eval data.\n\n Args:\n ...
def playbook_path(playbook_name): '\n Get the path to the named playbook. To allow for\n as much brevity as possible in the given playbook\n name, we will attempt to search under:\n - oct/playbooks\n - openshift-ansible/playbooks\n\n :param playbook_name: the name of the playbook\n :type pl...
-6,925,699,650,955,053,000
Get the path to the named playbook. To allow for as much brevity as possible in the given playbook name, we will attempt to search under: - oct/playbooks - openshift-ansible/playbooks :param playbook_name: the name of the playbook :type playbook_name: str :return: the path to the playbook :rtype: str :raises Cli...
oct/util/playbook.py
playbook_path
DennisPeriquet/origin-ci-tool
python
def playbook_path(playbook_name): '\n Get the path to the named playbook. To allow for\n as much brevity as possible in the given playbook\n name, we will attempt to search under:\n - oct/playbooks\n - openshift-ansible/playbooks\n\n :param playbook_name: the name of the playbook\n :type pl...
def test_location_handles_reused(instance, monkeypatch, grpc_server_registry): '\n verifies that only one repository location is created when two queued runs from the same\n location are dequeued in the same iteration\n ' create_run(instance, run_id='queued-run', status=PipelineRunStatus.QUEUED) cr...
7,905,741,415,444,816,000
verifies that only one repository location is created when two queued runs from the same location are dequeued in the same iteration
python_modules/dagster/dagster_tests/daemon_tests/test_queued_run_coordinator_daemon.py
test_location_handles_reused
PenguinToast/dagster
python
def test_location_handles_reused(instance, monkeypatch, grpc_server_registry): '\n verifies that only one repository location is created when two queued runs from the same\n location are dequeued in the same iteration\n ' create_run(instance, run_id='queued-run', status=PipelineRunStatus.QUEUED) cr...
def _update_dag_tasks(function_name, caller_line, dependencies, depends_logic, args=None, template_name=None, step_name=None): '\n A task in DAG of Argo YAML contains name, related template and parameters.\n Here we insert a single task into the global tasks.\n ' if (step_name is None): functio...
2,822,368,232,564,738,600
A task in DAG of Argo YAML contains name, related template and parameters. Here we insert a single task into the global tasks.
couler/core/step_update_utils.py
_update_dag_tasks
javoweb/couler
python
def _update_dag_tasks(function_name, caller_line, dependencies, depends_logic, args=None, template_name=None, step_name=None): '\n A task in DAG of Argo YAML contains name, related template and parameters.\n Here we insert a single task into the global tasks.\n ' if (step_name is None): functio...
def _update_steps(function_name, caller_line, args=None, template_name=None): '\n A step in Argo YAML contains name, related template and parameters.\n Here we insert a single step into the global steps.\n ' function_id = utils.invocation_name(function_name, caller_line) if states._update_steps_loc...
-1,058,683,839,742,048,800
A step in Argo YAML contains name, related template and parameters. Here we insert a single step into the global steps.
couler/core/step_update_utils.py
_update_steps
javoweb/couler
python
def _update_steps(function_name, caller_line, args=None, template_name=None): '\n A step in Argo YAML contains name, related template and parameters.\n Here we insert a single step into the global steps.\n ' function_id = utils.invocation_name(function_name, caller_line) if states._update_steps_loc...
@contextmanager def silence_stderr(): ' Redirect stderr. ' if DEBUG: (yield) else: with threading.Lock(): stderr = sys.stderr sys.stderr = StringIO() (yield) with threading.Lock(): sys.stderr = stderr
-2,169,894,562,685,810,000
Redirect stderr.
bundle/python-mode/pymode/utils.py
silence_stderr
Jenkin0603/myvim
python
@contextmanager def silence_stderr(): ' ' if DEBUG: (yield) else: with threading.Lock(): stderr = sys.stderr sys.stderr = StringIO() (yield) with threading.Lock(): sys.stderr = stderr
def patch_paths(): ' Function description. ' sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'libs')) if PY2: sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'libs2')) else: sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'libs3'))
-1,636,797,612,643,356,200
Function description.
bundle/python-mode/pymode/utils.py
patch_paths
Jenkin0603/myvim
python
def patch_paths(): ' ' sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'libs')) if PY2: sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'libs2')) else: sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'libs3'))
@abstractmethod def eval(self, tokens: List[str]) -> bool: 'If the given tokens sequence matches the given command execute it\n and return True. Otherwise, return False.\n\n Parameters\n ----------\n tokens: list(string)\n List of tokens in the command line\n\n Returns\...
-3,451,811,905,667,464,000
If the given tokens sequence matches the given command execute it and return True. Otherwise, return False. Parameters ---------- tokens: list(string) List of tokens in the command line Returns ------- bool
vizier/api/client/cli/command.py
eval
VizierDB/web-api-async
python
@abstractmethod def eval(self, tokens: List[str]) -> bool: 'If the given tokens sequence matches the given command execute it\n and return True. Otherwise, return False.\n\n Parameters\n ----------\n tokens: list(string)\n List of tokens in the command line\n\n Returns\...
@abstractmethod def help(self) -> None: 'Print a simple help statement for the command.' raise NotImplementedError()
592,158,047,742,548,200
Print a simple help statement for the command.
vizier/api/client/cli/command.py
help
VizierDB/web-api-async
python
@abstractmethod def help(self) -> None: raise NotImplementedError()
def output(self, rows): 'Output the given rows in tabular format. Each rows is a list of\n string values. All rows are expected to have the sam elength. The first\n row is the table header.\n\n Parameters\n ----------\n rows: list(string)\n List of rows in the table\n ...
8,790,974,993,255,597,000
Output the given rows in tabular format. Each rows is a list of string values. All rows are expected to have the sam elength. The first row is the table header. Parameters ---------- rows: list(string) List of rows in the table
vizier/api/client/cli/command.py
output
VizierDB/web-api-async
python
def output(self, rows): 'Output the given rows in tabular format. Each rows is a list of\n string values. All rows are expected to have the sam elength. The first\n row is the table header.\n\n Parameters\n ----------\n rows: list(string)\n List of rows in the table\n ...
def ProcessTag(self, line, type): '\n Process a single string tag.\n \n :param line: an array of lines making a single string tag.\n :param type: the tag type, such as TYPE_STR or TYPE_PLUR\n :return: an array of lines representing the processed tag.\n ' return line
-3,578,550,112,715,211,000
Process a single string tag. :param line: an array of lines making a single string tag. :param type: the tag type, such as TYPE_STR or TYPE_PLUR :return: an array of lines representing the processed tag.
scripts/translations/base_string_script.py
ProcessTag
1y445rc/FirebaseUI-Android
python
def ProcessTag(self, line, type): '\n Process a single string tag.\n \n :param line: an array of lines making a single string tag.\n :param type: the tag type, such as TYPE_STR or TYPE_PLUR\n :return: an array of lines representing the processed tag.\n ' return line
def ProcessFile(self, file_name): '\n Process and write a file of string resources.\n \n :param file_name: path to the file to process.\n :return: None.\n ' lines = [] state = self.STATE_SEARCHING curr_tag = [] pending_process_type = None with open(file_name, 'r') as myfile: ...
-1,617,482,522,694,352,400
Process and write a file of string resources. :param file_name: path to the file to process. :return: None.
scripts/translations/base_string_script.py
ProcessFile
1y445rc/FirebaseUI-Android
python
def ProcessFile(self, file_name): '\n Process and write a file of string resources.\n \n :param file_name: path to the file to process.\n :return: None.\n ' lines = [] state = self.STATE_SEARCHING curr_tag = [] pending_process_type = None with open(file_name, 'r') as myfile: ...
def WriteFile(self, file_name, file_contents): '\n Overwrite the contents of a file.\n \n :param file_name: path to the file to write.\n :param file_contents: string containing new file contents. \n :return: None\n ' with open(file_name, 'w') as myfile: myfile.write(file_contents)
3,607,157,379,932,279,000
Overwrite the contents of a file. :param file_name: path to the file to write. :param file_contents: string containing new file contents. :return: None
scripts/translations/base_string_script.py
WriteFile
1y445rc/FirebaseUI-Android
python
def WriteFile(self, file_name, file_contents): '\n Overwrite the contents of a file.\n \n :param file_name: path to the file to write.\n :param file_contents: string containing new file contents. \n :return: None\n ' with open(file_name, 'w') as myfile: myfile.write(file_contents)
def __init__(self, config_entry: config_entries.ConfigEntry) -> None: 'Init object.' self.config_entry = config_entry
-2,559,020,865,665,428,000
Init object.
homeassistant/components/netgear/config_flow.py
__init__
2004happy/core
python
def __init__(self, config_entry: config_entries.ConfigEntry) -> None: self.config_entry = config_entry
async def async_step_init(self, user_input=None): 'Manage the options.' if (user_input is not None): return self.async_create_entry(title='', data=user_input) settings_schema = vol.Schema({vol.Optional(CONF_CONSIDER_HOME, default=self.config_entry.options.get(CONF_CONSIDER_HOME, DEFAULT_CONSIDER_HOM...
6,396,657,444,366,347,000
Manage the options.
homeassistant/components/netgear/config_flow.py
async_step_init
2004happy/core
python
async def async_step_init(self, user_input=None): if (user_input is not None): return self.async_create_entry(title=, data=user_input) settings_schema = vol.Schema({vol.Optional(CONF_CONSIDER_HOME, default=self.config_entry.options.get(CONF_CONSIDER_HOME, DEFAULT_CONSIDER_HOME.total_seconds())): in...
def __init__(self): 'Initialize the netgear config flow.' self.placeholders = {CONF_HOST: DEFAULT_HOST, CONF_PORT: DEFAULT_PORT, CONF_USERNAME: DEFAULT_USER, CONF_SSL: False} self.discovered = False
-8,401,081,290,602,939,000
Initialize the netgear config flow.
homeassistant/components/netgear/config_flow.py
__init__
2004happy/core
python
def __init__(self): self.placeholders = {CONF_HOST: DEFAULT_HOST, CONF_PORT: DEFAULT_PORT, CONF_USERNAME: DEFAULT_USER, CONF_SSL: False} self.discovered = False
@staticmethod @callback def async_get_options_flow(config_entry: config_entries.ConfigEntry) -> OptionsFlowHandler: 'Get the options flow.' return OptionsFlowHandler(config_entry)
46,051,271,963,521,970
Get the options flow.
homeassistant/components/netgear/config_flow.py
async_get_options_flow
2004happy/core
python
@staticmethod @callback def async_get_options_flow(config_entry: config_entries.ConfigEntry) -> OptionsFlowHandler: return OptionsFlowHandler(config_entry)
async def _show_setup_form(self, user_input=None, errors=None): 'Show the setup form to the user.' if (not user_input): user_input = {} if self.discovered: data_schema = _discovery_schema_with_defaults(user_input) else: data_schema = _user_schema_with_defaults(user_input) ret...
5,815,990,346,358,273,000
Show the setup form to the user.
homeassistant/components/netgear/config_flow.py
_show_setup_form
2004happy/core
python
async def _show_setup_form(self, user_input=None, errors=None): if (not user_input): user_input = {} if self.discovered: data_schema = _discovery_schema_with_defaults(user_input) else: data_schema = _user_schema_with_defaults(user_input) return self.async_show_form(step_id='...
async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult: 'Initialize flow from ssdp.' updated_data: dict[(str, ((str | int) | bool))] = {} device_url = urlparse(discovery_info.ssdp_location) if (hostname := device_url.hostname): hostname = cast(str, hostname) ...
-1,430,843,196,014,504,200
Initialize flow from ssdp.
homeassistant/components/netgear/config_flow.py
async_step_ssdp
2004happy/core
python
async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult: updated_data: dict[(str, ((str | int) | bool))] = {} device_url = urlparse(discovery_info.ssdp_location) if (hostname := device_url.hostname): hostname = cast(str, hostname) updated_data[CONF_HOST] = ho...
async def async_step_user(self, user_input=None): 'Handle a flow initiated by the user.' errors = {} if (user_input is None): return (await self._show_setup_form()) host = user_input.get(CONF_HOST, self.placeholders[CONF_HOST]) port = self.placeholders[CONF_PORT] ssl = self.placeholders[...
-6,443,958,358,770,587,000
Handle a flow initiated by the user.
homeassistant/components/netgear/config_flow.py
async_step_user
2004happy/core
python
async def async_step_user(self, user_input=None): errors = {} if (user_input is None): return (await self._show_setup_form()) host = user_input.get(CONF_HOST, self.placeholders[CONF_HOST]) port = self.placeholders[CONF_PORT] ssl = self.placeholders[CONF_SSL] username = user_input.ge...