Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
named_colorscales | () |
Returns lowercased names of built-in continuous colorscales.
|
Returns lowercased names of built-in continuous colorscales.
| def named_colorscales():
"""
Returns lowercased names of built-in continuous colorscales.
"""
from _plotly_utils.basevalidators import ColorscaleValidator
return [c for c in ColorscaleValidator("", "").named_colorscales] | [
"def",
"named_colorscales",
"(",
")",
":",
"from",
"_plotly_utils",
".",
"basevalidators",
"import",
"ColorscaleValidator",
"return",
"[",
"c",
"for",
"c",
"in",
"ColorscaleValidator",
"(",
"\"\"",
",",
"\"\"",
")",
".",
"named_colorscales",
"]"
] | [
801,
0
] | [
807,
69
] | python | en | ['en', 'error', 'th'] | False |
_normalize | (tensor, norm_layer) |
Broadcast layer norm.
|
Broadcast layer norm.
| def _normalize(tensor, norm_layer):
"""
Broadcast layer norm.
"""
is_cpu = tensor.device == 'cpu' or tensor.device.type == 'cpu'
if APEX_LAYER_NORM and not is_cpu:
# fused_layer_norm has a bug around multi-device networks.
# https://github.com/NVIDIA/apex/issues/770
# https:/... | [
"def",
"_normalize",
"(",
"tensor",
",",
"norm_layer",
")",
":",
"is_cpu",
"=",
"tensor",
".",
"device",
"==",
"'cpu'",
"or",
"tensor",
".",
"device",
".",
"type",
"==",
"'cpu'",
"if",
"APEX_LAYER_NORM",
"and",
"not",
"is_cpu",
":",
"# fused_layer_norm has a... | [
43,
0
] | [
55,
33
] | python | en | ['en', 'error', 'th'] | False |
_create_embeddings | (dictionary, embedding_size, padding_idx) |
Create and initialize word embeddings.
|
Create and initialize word embeddings.
| def _create_embeddings(dictionary, embedding_size, padding_idx):
"""
Create and initialize word embeddings.
"""
e = nn.Embedding(len(dictionary), embedding_size, padding_idx)
nn.init.normal_(e.weight, mean=0, std=embedding_size ** -0.5)
nn.init.constant_(e.weight[padding_idx], 0)
return e | [
"def",
"_create_embeddings",
"(",
"dictionary",
",",
"embedding_size",
",",
"padding_idx",
")",
":",
"e",
"=",
"nn",
".",
"Embedding",
"(",
"len",
"(",
"dictionary",
")",
",",
"embedding_size",
",",
"padding_idx",
")",
"nn",
".",
"init",
".",
"normal_",
"(... | [
58,
0
] | [
65,
12
] | python | en | ['en', 'error', 'th'] | False |
get_n_positions_from_options | (opt) |
Determine n_positions from options dict.
|
Determine n_positions from options dict.
| def get_n_positions_from_options(opt):
"""
Determine n_positions from options dict.
"""
if opt.get('n_positions'):
# if the number of positions is explicitly provided, use that
n_positions = opt['n_positions']
else:
# else, use the worst case from truncate
n_positions... | [
"def",
"get_n_positions_from_options",
"(",
"opt",
")",
":",
"if",
"opt",
".",
"get",
"(",
"'n_positions'",
")",
":",
"# if the number of positions is explicitly provided, use that",
"n_positions",
"=",
"opt",
"[",
"'n_positions'",
"]",
"else",
":",
"# else, use the wor... | [
68,
0
] | [
84,
22
] | python | en | ['en', 'error', 'th'] | False |
create_position_codes | (n_pos, dim, out) |
Create positional codes and store them in ``out``.
|
Create positional codes and store them in ``out``.
| def create_position_codes(n_pos, dim, out):
"""
Create positional codes and store them in ``out``.
"""
position_enc = np.array(
[
[pos / np.power(10000, 2 * j / dim) for j in range(dim // 2)]
for pos in range(n_pos)
]
)
out.detach_()
out.requires_grad... | [
"def",
"create_position_codes",
"(",
"n_pos",
",",
"dim",
",",
"out",
")",
":",
"position_enc",
"=",
"np",
".",
"array",
"(",
"[",
"[",
"pos",
"/",
"np",
".",
"power",
"(",
"10000",
",",
"2",
"*",
"j",
"/",
"dim",
")",
"for",
"j",
"in",
"range",
... | [
270,
0
] | [
284,
71
] | python | en | ['en', 'error', 'th'] | False |
TransformerMemNetModel.encode_cand | (self, words) |
Encode the candidates.
|
Encode the candidates.
| def encode_cand(self, words):
"""
Encode the candidates.
"""
if words is None:
return None
# flatten if there are many candidates
if words.dim() == 3:
oldshape = words.shape
words = words.reshape(oldshape[0] * oldshape[1], oldshape[2])... | [
"def",
"encode_cand",
"(",
"self",
",",
"words",
")",
":",
"if",
"words",
"is",
"None",
":",
"return",
"None",
"# flatten if there are many candidates",
"if",
"words",
".",
"dim",
"(",
")",
"==",
"3",
":",
"oldshape",
"=",
"words",
".",
"shape",
"words",
... | [
199,
4
] | [
218,
22
] | python | en | ['en', 'error', 'th'] | False |
TransformerMemNetModel.encode_context_memory | (self, context_w, memories_w, context_segments=None) |
Encode the context and memories.
|
Encode the context and memories.
| def encode_context_memory(self, context_w, memories_w, context_segments=None):
"""
Encode the context and memories.
"""
# [batch, d]
if context_w is None:
# it's possible that only candidates were passed into the
# forward function, return None here for LH... | [
"def",
"encode_context_memory",
"(",
"self",
",",
"context_w",
",",
"memories_w",
",",
"context_segments",
"=",
"None",
")",
":",
"# [batch, d]",
"if",
"context_w",
"is",
"None",
":",
"# it's possible that only candidates were passed into the",
"# forward function, return N... | [
220,
4
] | [
243,
33
] | python | en | ['en', 'error', 'th'] | False |
TransformerMemNetModel.forward | (self, xs, mems, cands, context_segments=None) |
Forward pass.
:param LongTensor[batch,seqlen] xs: input tokens IDs
:param LongTensor[batch,num_mems,seqlen] mems: memory token IDs
:param LongTensor[batch,num_cands,seqlen] cands: candidate token IDs
:param LongTensor[batch,seqlen] context_segments: segment IDs for xs,
... |
Forward pass. | def forward(self, xs, mems, cands, context_segments=None):
"""
Forward pass.
:param LongTensor[batch,seqlen] xs: input tokens IDs
:param LongTensor[batch,num_mems,seqlen] mems: memory token IDs
:param LongTensor[batch,num_cands,seqlen] cands: candidate token IDs
:param L... | [
"def",
"forward",
"(",
"self",
",",
"xs",
",",
"mems",
",",
"cands",
",",
"context_segments",
"=",
"None",
")",
":",
"# encode the context and memories together",
"weights",
",",
"context_h",
"=",
"self",
".",
"encode_context_memory",
"(",
"xs",
",",
"mems",
"... | [
245,
4
] | [
267,
33
] | python | en | ['en', 'error', 'th'] | False |
TransformerResponseWrapper.forward | (self, *args) |
Forward pass.
|
Forward pass.
| def forward(self, *args):
"""
Forward pass.
"""
return self.mlp(self.transformer(*args)) | [
"def",
"forward",
"(",
"self",
",",
"*",
"args",
")",
":",
"return",
"self",
".",
"mlp",
"(",
"self",
".",
"transformer",
"(",
"*",
"args",
")",
")"
] | [
304,
4
] | [
308,
48
] | python | en | ['en', 'error', 'th'] | False |
TransformerLinearWrapper.forward | (self, *args) |
Forward pass.
Apply transformer, then additional linear layer.
|
Forward pass. | def forward(self, *args):
"""
Forward pass.
Apply transformer, then additional linear layer.
"""
context_h = self.transformer(*args)
return self.additional_linear_layer(context_h) | [
"def",
"forward",
"(",
"self",
",",
"*",
"args",
")",
":",
"context_h",
"=",
"self",
".",
"transformer",
"(",
"*",
"args",
")",
"return",
"self",
".",
"additional_linear_layer",
"(",
"context_h",
")"
] | [
322,
4
] | [
329,
54
] | python | en | ['en', 'error', 'th'] | False |
TransformerEncoder.forward_embedding | (
self,
input: torch.LongTensor,
positions: Optional[torch.LongTensor] = None,
segments: Optional[torch.LongTensor] = None,
) |
Embed tokens prior to feeding into transformer.
:param LongTensor[batch,seqlen] input:
The input IDs
:param LongTensor[batch,seqlen] positions:
Positions for input IDs
:param LongTensor[batch,seqlen]:
If provided, additionally adds ``segments`` as ex... |
Embed tokens prior to feeding into transformer. | def forward_embedding(
self,
input: torch.LongTensor,
positions: Optional[torch.LongTensor] = None,
segments: Optional[torch.LongTensor] = None,
) -> Tuple[torch.Tensor, torch.BoolTensor]:
"""
Embed tokens prior to feeding into transformer.
:param LongTensor[... | [
"def",
"forward_embedding",
"(",
"self",
",",
"input",
":",
"torch",
".",
"LongTensor",
",",
"positions",
":",
"Optional",
"[",
"torch",
".",
"LongTensor",
"]",
"=",
"None",
",",
"segments",
":",
"Optional",
"[",
"torch",
".",
"LongTensor",
"]",
"=",
"No... | [
471,
4
] | [
512,
27
] | python | en | ['en', 'error', 'th'] | False |
TransformerEncoder.forward_layers | (
self, tensor: torch.Tensor, mask: torch.BoolTensor
) |
Apply transformer layers to input.
:param tensor:
embedded input
:param mask:
mask of input
:return tensor:
return embedding after applying transformer layers
|
Apply transformer layers to input. | def forward_layers(
self, tensor: torch.Tensor, mask: torch.BoolTensor
) -> torch.Tensor:
"""
Apply transformer layers to input.
:param tensor:
embedded input
:param mask:
mask of input
:return tensor:
return embedding after apply... | [
"def",
"forward_layers",
"(",
"self",
",",
"tensor",
":",
"torch",
".",
"Tensor",
",",
"mask",
":",
"torch",
".",
"BoolTensor",
")",
"->",
"torch",
".",
"Tensor",
":",
"if",
"getattr",
"(",
"self",
".",
"layers",
",",
"'is_model_parallel'",
",",
"False",... | [
514,
4
] | [
536,
21
] | python | en | ['en', 'error', 'th'] | False |
TransformerEncoder.reduce_output | (
self, tensor: torch.Tensor, mask: torch.BoolTensor
) |
Reduce transformer output at end of forward pass.
:param tensor:
encoded input
:param mask:
mask for encoded input
:return (tensor, mask):
returns the reduced tensor, and mask if appropriate
|
Reduce transformer output at end of forward pass. | def reduce_output(
self, tensor: torch.Tensor, mask: torch.BoolTensor
) -> Tuple[torch.Tensor, Optional[torch.BoolTensor]]:
"""
Reduce transformer output at end of forward pass.
:param tensor:
encoded input
:param mask:
mask for encoded input
... | [
"def",
"reduce_output",
"(",
"self",
",",
"tensor",
":",
"torch",
".",
"Tensor",
",",
"mask",
":",
"torch",
".",
"BoolTensor",
")",
"->",
"Tuple",
"[",
"torch",
".",
"Tensor",
",",
"Optional",
"[",
"torch",
".",
"BoolTensor",
"]",
"]",
":",
"tensor",
... | [
538,
4
] | [
566,
13
] | python | en | ['en', 'error', 'th'] | False |
TransformerEncoder.forward | ( # type: ignore
self,
input: torch.LongTensor,
positions: Optional[torch.LongTensor] = None,
segments: Optional[torch.LongTensor] = None,
) |
Forward pass.
:param LongTensor[batch,seqlen] input:
The input IDs
:param LongTensor[batch,seqlen] positions:
Positions for input IDs
:param LongTensor[batch,seqlen] segments:
If provided, additionally adds ``segments`` as extra embedding features.
... |
Forward pass. | def forward( # type: ignore
self,
input: torch.LongTensor,
positions: Optional[torch.LongTensor] = None,
segments: Optional[torch.LongTensor] = None,
) -> Union[torch.Tensor, Tuple[torch.Tensor, torch.BoolTensor]]:
"""
Forward pass.
:param LongTensor[batch,s... | [
"def",
"forward",
"(",
"# type: ignore",
"self",
",",
"input",
":",
"torch",
".",
"LongTensor",
",",
"positions",
":",
"Optional",
"[",
"torch",
".",
"LongTensor",
"]",
"=",
"None",
",",
"segments",
":",
"Optional",
"[",
"torch",
".",
"LongTensor",
"]",
... | [
568,
4
] | [
606,
25
] | python | en | ['en', 'error', 'th'] | False |
TransformerEncoder._apply_model_parallel | (self, tensor, mask) |
Pipeline application of model parallelism.
|
Pipeline application of model parallelism.
| def _apply_model_parallel(self, tensor, mask):
"""
Pipeline application of model parallelism.
"""
chunks = PipelineHelper.split((tensor, mask))
work_items = PipelineHelper.schedule_work_items(self.layers, chunks)
for chunk_idx, layer_nos, next_device in work_items:
... | [
"def",
"_apply_model_parallel",
"(",
"self",
",",
"tensor",
",",
"mask",
")",
":",
"chunks",
"=",
"PipelineHelper",
".",
"split",
"(",
"(",
"tensor",
",",
"mask",
")",
")",
"work_items",
"=",
"PipelineHelper",
".",
"schedule_work_items",
"(",
"self",
".",
... | [
608,
4
] | [
622,
25
] | python | en | ['en', 'error', 'th'] | False |
TransformerEncoderLayer.forward | (self, tensor, mask) |
Forward pass.
|
Forward pass.
| def forward(self, tensor, mask):
"""
Forward pass.
"""
residual = tensor
if self.variant == 'prelayernorm':
tensor = _normalize(tensor, self.norm1)
attended_tensor = self.attention(tensor, mask=mask)[0]
tensor = residual + self.dropout(attended_tensor)... | [
"def",
"forward",
"(",
"self",
",",
"tensor",
",",
"mask",
")",
":",
"residual",
"=",
"tensor",
"if",
"self",
".",
"variant",
"==",
"'prelayernorm'",
":",
"tensor",
"=",
"_normalize",
"(",
"tensor",
",",
"self",
".",
"norm1",
")",
"attended_tensor",
"=",... | [
659,
4
] | [
677,
21
] | python | en | ['en', 'error', 'th'] | False |
TransformerDecoder.forward_embedding | (
self,
input: torch.LongTensor,
positions: Optional[torch.LongTensor] = None,
segments: Optional[torch.LongTensor] = None,
) |
Embed tokens prior to feeding into transformer.
:param LongTensor[batch, seqlen] input:
The target input IDs
:param LongTensor[batch, seqlen] positions:
Positions for input IDs. If None, computes defaults.
:param LongTensor[batch, seqlen] segements:
... |
Embed tokens prior to feeding into transformer. | def forward_embedding(
self,
input: torch.LongTensor,
positions: Optional[torch.LongTensor] = None,
segments: Optional[torch.LongTensor] = None,
):
"""
Embed tokens prior to feeding into transformer.
:param LongTensor[batch, seqlen] input:
The tar... | [
"def",
"forward_embedding",
"(",
"self",
",",
"input",
":",
"torch",
".",
"LongTensor",
",",
"positions",
":",
"Optional",
"[",
"torch",
".",
"LongTensor",
"]",
"=",
"None",
",",
"segments",
":",
"Optional",
"[",
"torch",
".",
"LongTensor",
"]",
"=",
"No... | [
785,
4
] | [
820,
21
] | python | en | ['en', 'error', 'th'] | False |
TransformerDecoder.forward_layers | (
self,
tensor: torch.Tensor,
encoder_output: torch.Tensor,
encoder_mask: torch.Tensor,
incr_state: Dict[int, torch.Tensor],
) |
Forward pass of decoder layers.
:param tensor:
embedded input tensor for the decoder
:param enc_out:
encoder outputs
:param enc_mask:
encoder output mask
:param incr_state:
Dict mapping layer_idx to incremental state
:ret... |
Forward pass of decoder layers. | def forward_layers(
self,
tensor: torch.Tensor,
encoder_output: torch.Tensor,
encoder_mask: torch.Tensor,
incr_state: Dict[int, torch.Tensor],
) -> Tuple[torch.Tensor, Dict[str, torch.Tensor]]:
"""
Forward pass of decoder layers.
:param tensor:
... | [
"def",
"forward_layers",
"(",
"self",
",",
"tensor",
":",
"torch",
".",
"Tensor",
",",
"encoder_output",
":",
"torch",
".",
"Tensor",
",",
"encoder_mask",
":",
"torch",
".",
"Tensor",
",",
"incr_state",
":",
"Dict",
"[",
"int",
",",
"torch",
".",
"Tensor... | [
822,
4
] | [
859,
37
] | python | en | ['en', 'error', 'th'] | False |
TransformerDecoder.forward | (self, input, encoder_state, incr_state=None) |
Forward pass.
:param LongTensor[batch,seqlen] input:
The decoder inputs (partial or full decoded token IDs).
:param encoder_state:
Output from the encoder module forward pass.
:param incr_state:
The incremental state: a dictionary whose keys index th... |
Forward pass. | def forward(self, input, encoder_state, incr_state=None):
"""
Forward pass.
:param LongTensor[batch,seqlen] input:
The decoder inputs (partial or full decoded token IDs).
:param encoder_state:
Output from the encoder module forward pass.
:param incr_state... | [
"def",
"forward",
"(",
"self",
",",
"input",
",",
"encoder_state",
",",
"incr_state",
"=",
"None",
")",
":",
"encoder_output",
",",
"encoder_mask",
"=",
"encoder_state",
"seq_len",
"=",
"input",
".",
"size",
"(",
"1",
")",
"positions",
"=",
"input",
".",
... | [
861,
4
] | [
898,
37
] | python | en | ['en', 'error', 'th'] | False |
TransformerDecoder._apply_model_parallel | (self, tensor, encoder_output, encoder_mask, incr_state) |
Pipeline application of model parallelism.
|
Pipeline application of model parallelism.
| def _apply_model_parallel(self, tensor, encoder_output, encoder_mask, incr_state):
"""
Pipeline application of model parallelism.
"""
chunks = PipelineHelper.split(
(tensor, encoder_output, encoder_mask, incr_state)
)
work_items = PipelineHelper.schedule_work_... | [
"def",
"_apply_model_parallel",
"(",
"self",
",",
"tensor",
",",
"encoder_output",
",",
"encoder_mask",
",",
"incr_state",
")",
":",
"chunks",
"=",
"PipelineHelper",
".",
"split",
"(",
"(",
"tensor",
",",
"encoder_output",
",",
"encoder_mask",
",",
"incr_state",... | [
900,
4
] | [
933,
41
] | python | en | ['en', 'error', 'th'] | False |
TransformerDecoderLayer.forward | (self, x, encoder_output, encoder_mask, incr_state=None) |
Forward pass.
The incremental state is a dict with values for self- and encoder-attention
states.
|
Forward pass. | def forward(self, x, encoder_output, encoder_mask, incr_state=None):
"""
Forward pass.
The incremental state is a dict with values for self- and encoder-attention
states.
"""
if incr_state is None:
incr_state = {}
decoder_mask = self._create_selfatt... | [
"def",
"forward",
"(",
"self",
",",
"x",
",",
"encoder_output",
",",
"encoder_mask",
",",
"incr_state",
"=",
"None",
")",
":",
"if",
"incr_state",
"is",
"None",
":",
"incr_state",
"=",
"{",
"}",
"decoder_mask",
"=",
"self",
".",
"_create_selfattn_mask",
"(... | [
979,
4
] | [
1039,
32
] | python | en | ['en', 'error', 'th'] | False |
TransformerDecoderLayer.reorder_incremental_state | (
self, incremental_state: Dict[str, dict], inds: torch.Tensor
) |
Reorder all incremental-state tensors for this layer.
|
Reorder all incremental-state tensors for this layer.
| def reorder_incremental_state(
self, incremental_state: Dict[str, dict], inds: torch.Tensor
) -> Dict[str, dict]:
"""
Reorder all incremental-state tensors for this layer.
"""
attn_types = {
'self_attn': self.self_attention,
'encoder_attn': self.encode... | [
"def",
"reorder_incremental_state",
"(",
"self",
",",
"incremental_state",
":",
"Dict",
"[",
"str",
",",
"dict",
"]",
",",
"inds",
":",
"torch",
".",
"Tensor",
")",
"->",
"Dict",
"[",
"str",
",",
"dict",
"]",
":",
"attn_types",
"=",
"{",
"'self_attn'",
... | [
1051,
4
] | [
1066,
9
] | python | en | ['en', 'error', 'th'] | False |
TransformerGeneratorModel.reorder_encoder_states | (self, encoder_states, indices) |
Reorder the encoder states.
See ``TorchGeneratorModel.reorder_encoder_states`` for a description.
|
Reorder the encoder states. | def reorder_encoder_states(self, encoder_states, indices):
"""
Reorder the encoder states.
See ``TorchGeneratorModel.reorder_encoder_states`` for a description.
"""
enc, mask = encoder_states
if not torch.is_tensor(indices):
indices = torch.LongTensor(indices... | [
"def",
"reorder_encoder_states",
"(",
"self",
",",
"encoder_states",
",",
"indices",
")",
":",
"enc",
",",
"mask",
"=",
"encoder_states",
"if",
"not",
"torch",
".",
"is_tensor",
"(",
"indices",
")",
":",
"indices",
"=",
"torch",
".",
"LongTensor",
"(",
"in... | [
1185,
4
] | [
1196,
24
] | python | en | ['en', 'error', 'th'] | False |
TransformerGeneratorModel.reorder_decoder_incremental_state | (
self, incremental_state: Dict[int, dict], inds: torch.Tensor
) |
Reorder the decoder incremental state.
See ``TorchGeneratorModel.reorder_decoder_incremental_state`` for a description.
Here, incremental_state is a dict whose keys are layer indices and whose values
are dicts containing the incremental state for that layer.
|
Reorder the decoder incremental state. | def reorder_decoder_incremental_state(
self, incremental_state: Dict[int, dict], inds: torch.Tensor
) -> Dict[int, dict]:
"""
Reorder the decoder incremental state.
See ``TorchGeneratorModel.reorder_decoder_incremental_state`` for a description.
Here, incremental_state is a... | [
"def",
"reorder_decoder_incremental_state",
"(",
"self",
",",
"incremental_state",
":",
"Dict",
"[",
"int",
",",
"dict",
"]",
",",
"inds",
":",
"torch",
".",
"Tensor",
")",
"->",
"Dict",
"[",
"int",
",",
"dict",
"]",
":",
"return",
"{",
"idx",
":",
"la... | [
1198,
4
] | [
1212,
9
] | python | en | ['en', 'error', 'th'] | False |
TransformerGeneratorModel.output | (self, tensor) |
Compute output logits.
|
Compute output logits.
| def output(self, tensor):
"""
Compute output logits.
"""
# project back to vocabulary
output = F.linear(tensor, self.embeddings.weight)
# compatibility with fairseq: fairseq sometimes reuses BOS tokens and
# we need to force their probability of generation to be 0... | [
"def",
"output",
"(",
"self",
",",
"tensor",
")",
":",
"# project back to vocabulary",
"output",
"=",
"F",
".",
"linear",
"(",
"tensor",
",",
"self",
".",
"embeddings",
".",
"weight",
")",
"# compatibility with fairseq: fairseq sometimes reuses BOS tokens and",
"# we ... | [
1214,
4
] | [
1223,
21
] | python | en | ['en', 'error', 'th'] | False |
BasicAttention.forward | (self, xs, ys, mask_ys=None, values=None) |
Compute attention.
Attend over ys with query xs to obtain weights, then apply weights to
values (ys if yalues is None)
Args:
xs: B x query_len x dim (queries)
ys: B x key_len x dim (keys)
mask_ys: B x key_len (mask)
values: B x value_len... |
Compute attention. | def forward(self, xs, ys, mask_ys=None, values=None):
"""
Compute attention.
Attend over ys with query xs to obtain weights, then apply weights to
values (ys if yalues is None)
Args:
xs: B x query_len x dim (queries)
ys: B x key_len x dim (keys)
... | [
"def",
"forward",
"(",
"self",
",",
"xs",
",",
"ys",
",",
"mask_ys",
"=",
"None",
",",
"values",
"=",
"None",
")",
":",
"bsz",
"=",
"xs",
".",
"size",
"(",
"0",
")",
"y_len",
"=",
"ys",
".",
"size",
"(",
"1",
")",
"x_len",
"=",
"xs",
".",
"... | [
1240,
4
] | [
1279,
48
] | python | en | ['en', 'error', 'th'] | False |
MultiHeadAttention.forward | ( # type: ignore
# TODO: remove type ignore with pytorch 1.5:
# https://github.com/pytorch/pytorch/pull/31057
self,
query: torch.Tensor,
key: Optional[torch.Tensor] = None,
value: Optional[torch.Tensor] = None,
mask: torch.Tensor = None,
incr_state: Optio... |
Forward pass.
:param query: attention query
:param key: attention key
:param value: attention value
:param mask: tensor in which True means that we are allowing attention and False
means we are blocking it. Mask is:
- [B, key_len] (encoder self-attn and deco... |
Forward pass. | def forward( # type: ignore
# TODO: remove type ignore with pytorch 1.5:
# https://github.com/pytorch/pytorch/pull/31057
self,
query: torch.Tensor,
key: Optional[torch.Tensor] = None,
value: Optional[torch.Tensor] = None,
mask: torch.Tensor = None,
incr_s... | [
"def",
"forward",
"(",
"# type: ignore",
"# TODO: remove type ignore with pytorch 1.5:",
"# https://github.com/pytorch/pytorch/pull/31057",
"self",
",",
"query",
":",
"torch",
".",
"Tensor",
",",
"key",
":",
"Optional",
"[",
"torch",
".",
"Tensor",
"]",
"=",
"None",
"... | [
1307,
4
] | [
1446,
44
] | python | en | ['en', 'error', 'th'] | False |
MultiHeadAttention.reorder_incremental_state | (
self, incremental_state: Dict[str, torch.Tensor], inds: torch.Tensor
) |
Reorder the input incremental-state tensors.
|
Reorder the input incremental-state tensors.
| def reorder_incremental_state(
self, incremental_state: Dict[str, torch.Tensor], inds: torch.Tensor
) -> Dict[str, torch.Tensor]:
"""
Reorder the input incremental-state tensors.
"""
return {
key: torch.index_select(val, 0, inds.to(val.device)).contiguous()
... | [
"def",
"reorder_incremental_state",
"(",
"self",
",",
"incremental_state",
":",
"Dict",
"[",
"str",
",",
"torch",
".",
"Tensor",
"]",
",",
"inds",
":",
"torch",
".",
"Tensor",
")",
"->",
"Dict",
"[",
"str",
",",
"torch",
".",
"Tensor",
"]",
":",
"retur... | [
1448,
4
] | [
1457,
9
] | python | en | ['en', 'error', 'th'] | False |
TransformerFFN.forward | (self, x) |
Forward pass.
|
Forward pass.
| def forward(self, x):
"""
Forward pass.
"""
x = self.nonlinear(self.lin1(x))
x = self.relu_dropout(x) # --relu-dropout
x = self.lin2(x)
return x | [
"def",
"forward",
"(",
"self",
",",
"x",
")",
":",
"x",
"=",
"self",
".",
"nonlinear",
"(",
"self",
".",
"lin1",
"(",
"x",
")",
")",
"x",
"=",
"self",
".",
"relu_dropout",
"(",
"x",
")",
"# --relu-dropout",
"x",
"=",
"self",
".",
"lin2",
"(",
"... | [
1482,
4
] | [
1489,
16
] | python | en | ['en', 'error', 'th'] | False |
polygon_to_bitmap | (polygons, height, width) | Convert masks from the form of polygons to bitmaps.
Args:
polygons (list[ndarray]): masks in polygon representation
height (int): mask height
width (int): mask width
Return:
ndarray: the converted masks in bitmap representation
| Convert masks from the form of polygons to bitmaps. | def polygon_to_bitmap(polygons, height, width):
"""Convert masks from the form of polygons to bitmaps.
Args:
polygons (list[ndarray]): masks in polygon representation
height (int): mask height
width (int): mask width
Return:
ndarray: the converted masks in bitmap representa... | [
"def",
"polygon_to_bitmap",
"(",
"polygons",
",",
"height",
",",
"width",
")",
":",
"rles",
"=",
"maskUtils",
".",
"frPyObjects",
"(",
"polygons",
",",
"height",
",",
"width",
")",
"rle",
"=",
"maskUtils",
".",
"merge",
"(",
"rles",
")",
"bitmap_mask",
"... | [
560,
0
] | [
574,
22
] | python | en | ['en', 'en', 'en'] | True |
BaseInstanceMasks.rescale | (self, scale, interpolation='nearest') | Rescale masks as large as possible while keeping the aspect ratio.
For details can refer to `mmcv.imrescale`.
Args:
scale (tuple[int]): The maximum size (h, w) of rescaled mask.
interpolation (str): Same as :func:`mmcv.imrescale`.
Returns:
BaseInstanceMasks:... | Rescale masks as large as possible while keeping the aspect ratio.
For details can refer to `mmcv.imrescale`. | def rescale(self, scale, interpolation='nearest'):
"""Rescale masks as large as possible while keeping the aspect ratio.
For details can refer to `mmcv.imrescale`.
Args:
scale (tuple[int]): The maximum size (h, w) of rescaled mask.
interpolation (str): Same as :func:`mmc... | [
"def",
"rescale",
"(",
"self",
",",
"scale",
",",
"interpolation",
"=",
"'nearest'",
")",
":",
"pass"
] | [
13,
4
] | [
24,
12
] | python | en | ['en', 'en', 'en'] | True |
BaseInstanceMasks.resize | (self, out_shape, interpolation='nearest') | Resize masks to the given out_shape.
Args:
out_shape: Target (h, w) of resized mask.
interpolation (str): See :func:`mmcv.imresize`.
Returns:
BaseInstanceMasks: The resized masks.
| Resize masks to the given out_shape. | def resize(self, out_shape, interpolation='nearest'):
"""Resize masks to the given out_shape.
Args:
out_shape: Target (h, w) of resized mask.
interpolation (str): See :func:`mmcv.imresize`.
Returns:
BaseInstanceMasks: The resized masks.
"""
p... | [
"def",
"resize",
"(",
"self",
",",
"out_shape",
",",
"interpolation",
"=",
"'nearest'",
")",
":",
"pass"
] | [
27,
4
] | [
37,
12
] | python | en | ['en', 'en', 'en'] | True |
BaseInstanceMasks.flip | (self, flip_direction='horizontal') | Flip masks alone the given direction.
Args:
flip_direction (str): Either 'horizontal' or 'vertical'.
Returns:
BaseInstanceMasks: The flipped masks.
| Flip masks alone the given direction. | def flip(self, flip_direction='horizontal'):
"""Flip masks alone the given direction.
Args:
flip_direction (str): Either 'horizontal' or 'vertical'.
Returns:
BaseInstanceMasks: The flipped masks.
"""
pass | [
"def",
"flip",
"(",
"self",
",",
"flip_direction",
"=",
"'horizontal'",
")",
":",
"pass"
] | [
40,
4
] | [
49,
12
] | python | en | ['en', 'en', 'en'] | True |
BaseInstanceMasks.pad | (self, out_shape, pad_val) | Pad masks to the given size of (h, w).
Args:
out_shape (tuple[int]): Target (h, w) of padded mask.
pad_val (int): The padded value.
Returns:
BaseInstanceMasks: The padded masks.
| Pad masks to the given size of (h, w). | def pad(self, out_shape, pad_val):
"""Pad masks to the given size of (h, w).
Args:
out_shape (tuple[int]): Target (h, w) of padded mask.
pad_val (int): The padded value.
Returns:
BaseInstanceMasks: The padded masks.
"""
pass | [
"def",
"pad",
"(",
"self",
",",
"out_shape",
",",
"pad_val",
")",
":",
"pass"
] | [
52,
4
] | [
62,
12
] | python | en | ['en', 'en', 'en'] | True |
BaseInstanceMasks.crop | (self, bbox) | Crop each mask by the given bbox.
Args:
bbox (ndarray): Bbox in format [x1, y1, x2, y2], shape (4, ).
Return:
BaseInstanceMasks: The cropped masks.
| Crop each mask by the given bbox. | def crop(self, bbox):
"""Crop each mask by the given bbox.
Args:
bbox (ndarray): Bbox in format [x1, y1, x2, y2], shape (4, ).
Return:
BaseInstanceMasks: The cropped masks.
"""
pass | [
"def",
"crop",
"(",
"self",
",",
"bbox",
")",
":",
"pass"
] | [
65,
4
] | [
74,
12
] | python | en | ['en', 'en', 'en'] | True |
BaseInstanceMasks.crop_and_resize | (self,
bboxes,
out_shape,
inds,
device,
interpolation='bilinear') | Crop and resize masks by the given bboxes.
This function is mainly used in mask targets computation.
It firstly align mask to bboxes by assigned_inds, then crop mask by the
assigned bbox and resize to the size of (mask_h, mask_w)
Args:
bboxes (Tensor): Bboxes in format [x1,... | Crop and resize masks by the given bboxes. | def crop_and_resize(self,
bboxes,
out_shape,
inds,
device,
interpolation='bilinear'):
"""Crop and resize masks by the given bboxes.
This function is mainly used in mask targets comput... | [
"def",
"crop_and_resize",
"(",
"self",
",",
"bboxes",
",",
"out_shape",
",",
"inds",
",",
"device",
",",
"interpolation",
"=",
"'bilinear'",
")",
":",
"pass"
] | [
77,
4
] | [
99,
12
] | python | en | ['en', 'en', 'en'] | True |
BaseInstanceMasks.expand | (self, expanded_h, expanded_w, top, left) | see :class:`Expand`. | see :class:`Expand`. | def expand(self, expanded_h, expanded_w, top, left):
"""see :class:`Expand`."""
pass | [
"def",
"expand",
"(",
"self",
",",
"expanded_h",
",",
"expanded_w",
",",
"top",
",",
"left",
")",
":",
"pass"
] | [
102,
4
] | [
104,
12
] | python | en | ['en', 'en', 'en'] | False |
BaseInstanceMasks.areas | (self) | ndarray: areas of each instance. | ndarray: areas of each instance. | def areas(self):
"""ndarray: areas of each instance."""
pass | [
"def",
"areas",
"(",
"self",
")",
":",
"pass"
] | [
108,
4
] | [
110,
12
] | python | en | ['en', 'en', 'en'] | True |
BaseInstanceMasks.to_ndarray | (self) | Convert masks to the format of ndarray.
Return:
ndarray: Converted masks in the format of ndarray.
| Convert masks to the format of ndarray. | def to_ndarray(self):
"""Convert masks to the format of ndarray.
Return:
ndarray: Converted masks in the format of ndarray.
"""
pass | [
"def",
"to_ndarray",
"(",
"self",
")",
":",
"pass"
] | [
113,
4
] | [
119,
12
] | python | en | ['en', 'en', 'en'] | True |
BaseInstanceMasks.to_tensor | (self, dtype, device) | Convert masks to the format of Tensor.
Args:
dtype (str): Dtype of converted mask.
device (torch.device): Device of converted masks.
Returns:
Tensor: Converted masks in the format of Tensor.
| Convert masks to the format of Tensor. | def to_tensor(self, dtype, device):
"""Convert masks to the format of Tensor.
Args:
dtype (str): Dtype of converted mask.
device (torch.device): Device of converted masks.
Returns:
Tensor: Converted masks in the format of Tensor.
"""
pass | [
"def",
"to_tensor",
"(",
"self",
",",
"dtype",
",",
"device",
")",
":",
"pass"
] | [
122,
4
] | [
132,
12
] | python | en | ['en', 'en', 'en'] | True |
BitmapMasks.__getitem__ | (self, index) | Index the BitmapMask.
Args:
index (int | ndarray): Indices in the format of integer or ndarray.
Returns:
:obj:`BitmapMasks`: Indexed bitmap masks.
| Index the BitmapMask. | def __getitem__(self, index):
"""Index the BitmapMask.
Args:
index (int | ndarray): Indices in the format of integer or ndarray.
Returns:
:obj:`BitmapMasks`: Indexed bitmap masks.
"""
masks = self.masks[index].reshape(-1, self.height, self.width)
... | [
"def",
"__getitem__",
"(",
"self",
",",
"index",
")",
":",
"masks",
"=",
"self",
".",
"masks",
"[",
"index",
"]",
".",
"reshape",
"(",
"-",
"1",
",",
"self",
".",
"height",
",",
"self",
".",
"width",
")",
"return",
"BitmapMasks",
"(",
"masks",
",",... | [
162,
4
] | [
172,
58
] | python | en | ['en', 'zu', 'en'] | True |
BitmapMasks.__len__ | (self) | Number of masks. | Number of masks. | def __len__(self):
"""Number of masks."""
return len(self.masks) | [
"def",
"__len__",
"(",
"self",
")",
":",
"return",
"len",
"(",
"self",
".",
"masks",
")"
] | [
184,
4
] | [
186,
30
] | python | en | ['en', 'da', 'en'] | True |
BitmapMasks.rescale | (self, scale, interpolation='nearest') | See :func:`BaseInstanceMasks.rescale`. | See :func:`BaseInstanceMasks.rescale`. | def rescale(self, scale, interpolation='nearest'):
"""See :func:`BaseInstanceMasks.rescale`."""
if len(self.masks) == 0:
new_w, new_h = mmcv.rescale_size((self.width, self.height), scale)
rescaled_masks = np.empty((0, new_h, new_w), dtype=np.uint8)
else:
resca... | [
"def",
"rescale",
"(",
"self",
",",
"scale",
",",
"interpolation",
"=",
"'nearest'",
")",
":",
"if",
"len",
"(",
"self",
".",
"masks",
")",
"==",
"0",
":",
"new_w",
",",
"new_h",
"=",
"mmcv",
".",
"rescale_size",
"(",
"(",
"self",
".",
"width",
","... | [
188,
4
] | [
199,
57
] | python | en | ['en', 'en', 'de'] | False |
BitmapMasks.resize | (self, out_shape, interpolation='nearest') | See :func:`BaseInstanceMasks.resize`. | See :func:`BaseInstanceMasks.resize`. | def resize(self, out_shape, interpolation='nearest'):
"""See :func:`BaseInstanceMasks.resize`."""
if len(self.masks) == 0:
resized_masks = np.empty((0, *out_shape), dtype=np.uint8)
else:
resized_masks = np.stack([
mmcv.imresize(mask, out_shape, interpolati... | [
"def",
"resize",
"(",
"self",
",",
"out_shape",
",",
"interpolation",
"=",
"'nearest'",
")",
":",
"if",
"len",
"(",
"self",
".",
"masks",
")",
"==",
"0",
":",
"resized_masks",
"=",
"np",
".",
"empty",
"(",
"(",
"0",
",",
"*",
"out_shape",
")",
",",... | [
201,
4
] | [
210,
53
] | python | de | ['en', 'jv', 'de'] | False |
BitmapMasks.flip | (self, flip_direction='horizontal') | See :func:`BaseInstanceMasks.flip`. | See :func:`BaseInstanceMasks.flip`. | def flip(self, flip_direction='horizontal'):
"""See :func:`BaseInstanceMasks.flip`."""
assert flip_direction in ('horizontal', 'vertical')
if len(self.masks) == 0:
flipped_masks = self.masks
else:
flipped_masks = np.stack([
mmcv.imflip(mask, direc... | [
"def",
"flip",
"(",
"self",
",",
"flip_direction",
"=",
"'horizontal'",
")",
":",
"assert",
"flip_direction",
"in",
"(",
"'horizontal'",
",",
"'vertical'",
")",
"if",
"len",
"(",
"self",
".",
"masks",
")",
"==",
"0",
":",
"flipped_masks",
"=",
"self",
".... | [
212,
4
] | [
223,
66
] | python | de | ['en', 'de', 'de'] | False |
BitmapMasks.pad | (self, out_shape, pad_val=0) | See :func:`BaseInstanceMasks.pad`. | See :func:`BaseInstanceMasks.pad`. | def pad(self, out_shape, pad_val=0):
"""See :func:`BaseInstanceMasks.pad`."""
if len(self.masks) == 0:
padded_masks = np.empty((0, *out_shape), dtype=np.uint8)
else:
padded_masks = np.stack([
mmcv.impad(mask, shape=out_shape, pad_val=pad_val)
... | [
"def",
"pad",
"(",
"self",
",",
"out_shape",
",",
"pad_val",
"=",
"0",
")",
":",
"if",
"len",
"(",
"self",
".",
"masks",
")",
"==",
"0",
":",
"padded_masks",
"=",
"np",
".",
"empty",
"(",
"(",
"0",
",",
"*",
"out_shape",
")",
",",
"dtype",
"=",... | [
225,
4
] | [
234,
52
] | python | de | ['en', 'fil', 'de'] | False |
BitmapMasks.crop | (self, bbox) | See :func:`BaseInstanceMasks.crop`. | See :func:`BaseInstanceMasks.crop`. | def crop(self, bbox):
"""See :func:`BaseInstanceMasks.crop`."""
assert isinstance(bbox, np.ndarray)
assert bbox.ndim == 1
# clip the boundary
bbox = bbox.copy()
bbox[0::2] = np.clip(bbox[0::2], 0, self.width)
bbox[1::2] = np.clip(bbox[1::2], 0, self.height)
... | [
"def",
"crop",
"(",
"self",
",",
"bbox",
")",
":",
"assert",
"isinstance",
"(",
"bbox",
",",
"np",
".",
"ndarray",
")",
"assert",
"bbox",
".",
"ndim",
"==",
"1",
"# clip the boundary",
"bbox",
"=",
"bbox",
".",
"copy",
"(",
")",
"bbox",
"[",
"0",
"... | [
236,
4
] | [
253,
47
] | python | de | ['en', 'de', 'de'] | False |
BitmapMasks.crop_and_resize | (self,
bboxes,
out_shape,
inds,
device='cpu',
interpolation='bilinear') | See :func:`BaseInstanceMasks.crop_and_resize`. | See :func:`BaseInstanceMasks.crop_and_resize`. | def crop_and_resize(self,
bboxes,
out_shape,
inds,
device='cpu',
interpolation='bilinear'):
"""See :func:`BaseInstanceMasks.crop_and_resize`."""
if len(self.masks) == 0:
em... | [
"def",
"crop_and_resize",
"(",
"self",
",",
"bboxes",
",",
"out_shape",
",",
"inds",
",",
"device",
"=",
"'cpu'",
",",
"interpolation",
"=",
"'bilinear'",
")",
":",
"if",
"len",
"(",
"self",
".",
"masks",
")",
"==",
"0",
":",
"empty_masks",
"=",
"np",
... | [
255,
4
] | [
285,
53
] | python | en | ['en', 'en', 'de'] | False |
BitmapMasks.expand | (self, expanded_h, expanded_w, top, left) | See :func:`BaseInstanceMasks.expand`. | See :func:`BaseInstanceMasks.expand`. | def expand(self, expanded_h, expanded_w, top, left):
"""See :func:`BaseInstanceMasks.expand`."""
if len(self.masks) == 0:
expanded_mask = np.empty((0, expanded_h, expanded_w),
dtype=np.uint8)
else:
expanded_mask = np.zeros((len(self), ... | [
"def",
"expand",
"(",
"self",
",",
"expanded_h",
",",
"expanded_w",
",",
"top",
",",
"left",
")",
":",
"if",
"len",
"(",
"self",
".",
"masks",
")",
"==",
"0",
":",
"expanded_mask",
"=",
"np",
".",
"empty",
"(",
"(",
"0",
",",
"expanded_h",
",",
"... | [
287,
4
] | [
297,
65
] | python | en | ['en', 'en', 'de'] | False |
BitmapMasks.areas | (self) | See :py:attr:`BaseInstanceMasks.areas`. | See :py:attr:`BaseInstanceMasks.areas`. | def areas(self):
"""See :py:attr:`BaseInstanceMasks.areas`."""
return self.masks.sum((1, 2)) | [
"def",
"areas",
"(",
"self",
")",
":",
"return",
"self",
".",
"masks",
".",
"sum",
"(",
"(",
"1",
",",
"2",
")",
")"
] | [
300,
4
] | [
302,
37
] | python | de | ['en', 'de', 'de'] | False |
BitmapMasks.to_ndarray | (self) | See :func:`BaseInstanceMasks.to_ndarray`. | See :func:`BaseInstanceMasks.to_ndarray`. | def to_ndarray(self):
"""See :func:`BaseInstanceMasks.to_ndarray`."""
return self.masks | [
"def",
"to_ndarray",
"(",
"self",
")",
":",
"return",
"self",
".",
"masks"
] | [
304,
4
] | [
306,
25
] | python | en | ['en', 'en', 'hi'] | False |
BitmapMasks.to_tensor | (self, dtype, device) | See :func:`BaseInstanceMasks.to_tensor`. | See :func:`BaseInstanceMasks.to_tensor`. | def to_tensor(self, dtype, device):
"""See :func:`BaseInstanceMasks.to_tensor`."""
return torch.tensor(self.masks, dtype=dtype, device=device) | [
"def",
"to_tensor",
"(",
"self",
",",
"dtype",
",",
"device",
")",
":",
"return",
"torch",
".",
"tensor",
"(",
"self",
".",
"masks",
",",
"dtype",
"=",
"dtype",
",",
"device",
"=",
"device",
")"
] | [
308,
4
] | [
310,
67
] | python | en | ['en', 'en', 'de'] | False |
PolygonMasks.__getitem__ | (self, index) | Index the polygon masks.
Args:
index (ndarray | List): The indices.
Returns:
:obj:`PolygonMasks`: The indexed polygon masks.
| Index the polygon masks. | def __getitem__(self, index):
"""Index the polygon masks.
Args:
index (ndarray | List): The indices.
Returns:
:obj:`PolygonMasks`: The indexed polygon masks.
"""
if isinstance(index, np.ndarray):
index = index.tolist()
if isinstance(i... | [
"def",
"__getitem__",
"(",
"self",
",",
"index",
")",
":",
"if",
"isinstance",
"(",
"index",
",",
"np",
".",
"ndarray",
")",
":",
"index",
"=",
"index",
".",
"tolist",
"(",
")",
"if",
"isinstance",
"(",
"index",
",",
"list",
")",
":",
"masks",
"=",... | [
338,
4
] | [
359,
59
] | python | en | ['en', 'en', 'en'] | True |
PolygonMasks.__len__ | (self) | Number of masks. | Number of masks. | def __len__(self):
"""Number of masks."""
return len(self.masks) | [
"def",
"__len__",
"(",
"self",
")",
":",
"return",
"len",
"(",
"self",
".",
"masks",
")"
] | [
371,
4
] | [
373,
30
] | python | en | ['en', 'da', 'en'] | True |
PolygonMasks.rescale | (self, scale, interpolation=None) | see :func:`BaseInstanceMasks.rescale` | see :func:`BaseInstanceMasks.rescale` | def rescale(self, scale, interpolation=None):
"""see :func:`BaseInstanceMasks.rescale`"""
new_w, new_h = mmcv.rescale_size((self.width, self.height), scale)
if len(self.masks) == 0:
rescaled_masks = PolygonMasks([], new_h, new_w)
else:
rescaled_masks = self.resize... | [
"def",
"rescale",
"(",
"self",
",",
"scale",
",",
"interpolation",
"=",
"None",
")",
":",
"new_w",
",",
"new_h",
"=",
"mmcv",
".",
"rescale_size",
"(",
"(",
"self",
".",
"width",
",",
"self",
".",
"height",
")",
",",
"scale",
")",
"if",
"len",
"(",... | [
375,
4
] | [
382,
29
] | python | en | ['en', 'en', 'it'] | False |
PolygonMasks.resize | (self, out_shape, interpolation=None) | see :func:`BaseInstanceMasks.resize` | see :func:`BaseInstanceMasks.resize` | def resize(self, out_shape, interpolation=None):
"""see :func:`BaseInstanceMasks.resize`"""
if len(self.masks) == 0:
resized_masks = PolygonMasks([], *out_shape)
else:
h_scale = out_shape[0] / self.height
w_scale = out_shape[1] / self.width
resized... | [
"def",
"resize",
"(",
"self",
",",
"out_shape",
",",
"interpolation",
"=",
"None",
")",
":",
"if",
"len",
"(",
"self",
".",
"masks",
")",
"==",
"0",
":",
"resized_masks",
"=",
"PolygonMasks",
"(",
"[",
"]",
",",
"*",
"out_shape",
")",
"else",
":",
... | [
384,
4
] | [
401,
28
] | python | en | ['en', 'jv', 'it'] | False |
PolygonMasks.flip | (self, flip_direction='horizontal') | see :func:`BaseInstanceMasks.flip` | see :func:`BaseInstanceMasks.flip` | def flip(self, flip_direction='horizontal'):
"""see :func:`BaseInstanceMasks.flip`"""
assert flip_direction in ('horizontal', 'vertical')
if len(self.masks) == 0:
flipped_masks = PolygonMasks([], self.height, self.width)
else:
if flip_direction == 'horizontal':
... | [
"def",
"flip",
"(",
"self",
",",
"flip_direction",
"=",
"'horizontal'",
")",
":",
"assert",
"flip_direction",
"in",
"(",
"'horizontal'",
",",
"'vertical'",
")",
"if",
"len",
"(",
"self",
".",
"masks",
")",
"==",
"0",
":",
"flipped_masks",
"=",
"PolygonMask... | [
403,
4
] | [
425,
28
] | python | de | ['en', 'de', 'it'] | False |
PolygonMasks.crop | (self, bbox) | see :func:`BaseInstanceMasks.crop` | see :func:`BaseInstanceMasks.crop` | def crop(self, bbox):
"""see :func:`BaseInstanceMasks.crop`"""
assert isinstance(bbox, np.ndarray)
assert bbox.ndim == 1
# clip the boundary
bbox = bbox.copy()
bbox[0::2] = np.clip(bbox[0::2], 0, self.width)
bbox[1::2] = np.clip(bbox[1::2], 0, self.height)
... | [
"def",
"crop",
"(",
"self",
",",
"bbox",
")",
":",
"assert",
"isinstance",
"(",
"bbox",
",",
"np",
".",
"ndarray",
")",
"assert",
"bbox",
".",
"ndim",
"==",
"1",
"# clip the boundary",
"bbox",
"=",
"bbox",
".",
"copy",
"(",
")",
"bbox",
"[",
"0",
"... | [
427,
4
] | [
454,
28
] | python | de | ['en', 'de', 'it'] | False |
PolygonMasks.pad | (self, out_shape, pad_val=0) | padding has no effect on polygons` | padding has no effect on polygons` | def pad(self, out_shape, pad_val=0):
"""padding has no effect on polygons`"""
return PolygonMasks(self.masks, *out_shape) | [
"def",
"pad",
"(",
"self",
",",
"out_shape",
",",
"pad_val",
"=",
"0",
")",
":",
"return",
"PolygonMasks",
"(",
"self",
".",
"masks",
",",
"*",
"out_shape",
")"
] | [
456,
4
] | [
458,
51
] | python | en | ['en', 'en', 'en'] | True |
PolygonMasks.expand | (self, *args, **kwargs) | TODO: Add expand for polygon | TODO: Add expand for polygon | def expand(self, *args, **kwargs):
"""TODO: Add expand for polygon"""
raise NotImplementedError | [
"def",
"expand",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"raise",
"NotImplementedError"
] | [
460,
4
] | [
462,
33
] | python | en | ['en', 'en', 'en'] | True |
PolygonMasks.crop_and_resize | (self,
bboxes,
out_shape,
inds,
device='cpu',
interpolation='bilinear') | see :func:`BaseInstanceMasks.crop_and_resize` | see :func:`BaseInstanceMasks.crop_and_resize` | def crop_and_resize(self,
bboxes,
out_shape,
inds,
device='cpu',
interpolation='bilinear'):
"""see :func:`BaseInstanceMasks.crop_and_resize`"""
out_h, out_w = out_shape
if len(... | [
"def",
"crop_and_resize",
"(",
"self",
",",
"bboxes",
",",
"out_shape",
",",
"inds",
",",
"device",
"=",
"'cpu'",
",",
"interpolation",
"=",
"'bilinear'",
")",
":",
"out_h",
",",
"out_w",
"=",
"out_shape",
"if",
"len",
"(",
"self",
".",
"masks",
")",
"... | [
464,
4
] | [
498,
54
] | python | en | ['en', 'en', 'en'] | False |
PolygonMasks.to_bitmap | (self) | convert polygon masks to bitmap masks. | convert polygon masks to bitmap masks. | def to_bitmap(self):
"""convert polygon masks to bitmap masks."""
bitmap_masks = self.to_ndarray()
return BitmapMasks(bitmap_masks, self.height, self.width) | [
"def",
"to_bitmap",
"(",
"self",
")",
":",
"bitmap_masks",
"=",
"self",
".",
"to_ndarray",
"(",
")",
"return",
"BitmapMasks",
"(",
"bitmap_masks",
",",
"self",
".",
"height",
",",
"self",
".",
"width",
")"
] | [
500,
4
] | [
503,
65
] | python | en | ['en', 'fil', 'en'] | True |
PolygonMasks.areas | (self) | Compute areas of masks.
This func is modified from
https://github.com/facebookresearch/detectron2/blob/ffff8acc35ea88ad1cb1806ab0f00b4c1c5dbfd9/detectron2/structures/masks.py#L387
Only works with Polygons, using the shoelace formula
Return:
ndarray: areas of each instance
... | Compute areas of masks. | def areas(self):
"""Compute areas of masks.
This func is modified from
https://github.com/facebookresearch/detectron2/blob/ffff8acc35ea88ad1cb1806ab0f00b4c1c5dbfd9/detectron2/structures/masks.py#L387
Only works with Polygons, using the shoelace formula
Return:
ndarr... | [
"def",
"areas",
"(",
"self",
")",
":",
"# noqa: W501",
"area",
"=",
"[",
"]",
"for",
"polygons_per_obj",
"in",
"self",
".",
"masks",
":",
"area_per_obj",
"=",
"0",
"for",
"p",
"in",
"polygons_per_obj",
":",
"area_per_obj",
"+=",
"self",
".",
"_polygon_area... | [
506,
4
] | [
522,
31
] | python | en | ['en', 'en', 'en'] | True |
PolygonMasks._polygon_area | (self, x, y) | Compute the area of a component of a polygon.
Using the shoelace formula:
https://stackoverflow.com/questions/24467972/calculate-area-of-polygon-given-x-y-coordinates
Args:
x (ndarray): x coordinates of the component
y (ndarray): y coordinates of the component
... | Compute the area of a component of a polygon. | def _polygon_area(self, x, y):
"""Compute the area of a component of a polygon.
Using the shoelace formula:
https://stackoverflow.com/questions/24467972/calculate-area-of-polygon-given-x-y-coordinates
Args:
x (ndarray): x coordinates of the component
y (ndarray)... | [
"def",
"_polygon_area",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"# noqa: 501",
"return",
"0.5",
"*",
"np",
".",
"abs",
"(",
"np",
".",
"dot",
"(",
"x",
",",
"np",
".",
"roll",
"(",
"y",
",",
"1",
")",
")",
"-",
"np",
".",
"dot",
"(",
"y"... | [
524,
4
] | [
538,
64
] | python | en | ['en', 'en', 'en'] | True |
PolygonMasks.to_ndarray | (self) | Convert masks to the format of ndarray. | Convert masks to the format of ndarray. | def to_ndarray(self):
"""Convert masks to the format of ndarray."""
if len(self.masks) == 0:
return np.empty((0, self.height, self.width), dtype=np.uint8)
bitmap_masks = []
for poly_per_obj in self.masks:
bitmap_masks.append(
polygon_to_bitmap(poly... | [
"def",
"to_ndarray",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"masks",
")",
"==",
"0",
":",
"return",
"np",
".",
"empty",
"(",
"(",
"0",
",",
"self",
".",
"height",
",",
"self",
".",
"width",
")",
",",
"dtype",
"=",
"np",
".",
"u... | [
540,
4
] | [
548,
37
] | python | en | ['en', 'en', 'en'] | True |
PolygonMasks.to_tensor | (self, dtype, device) | See :func:`BaseInstanceMasks.to_tensor`. | See :func:`BaseInstanceMasks.to_tensor`. | def to_tensor(self, dtype, device):
"""See :func:`BaseInstanceMasks.to_tensor`."""
if len(self.masks) == 0:
return torch.empty((0, self.height, self.width),
dtype=dtype,
device=device)
ndarray_masks = self.to_ndarray()
... | [
"def",
"to_tensor",
"(",
"self",
",",
"dtype",
",",
"device",
")",
":",
"if",
"len",
"(",
"self",
".",
"masks",
")",
"==",
"0",
":",
"return",
"torch",
".",
"empty",
"(",
"(",
"0",
",",
"self",
".",
"height",
",",
"self",
".",
"width",
")",
","... | [
550,
4
] | [
557,
70
] | python | en | ['en', 'en', 'de'] | False |
Font.color | (self) |
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color:
... |
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color:
... | def color(self):
"""
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A name... | [
"def",
"color",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"color\"",
"]"
] | [
15,
4
] | [
64,
28
] | python | en | ['en', 'error', 'th'] | False |
Font.colorsrc | (self) |
Sets the source reference on Chart Studio Cloud for color .
The 'colorsrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
|
Sets the source reference on Chart Studio Cloud for color .
The 'colorsrc' property must be specified as a string or
as a plotly.grid_objs.Column object | def colorsrc(self):
"""
Sets the source reference on Chart Studio Cloud for color .
The 'colorsrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
"""
return self["colorsrc"] | [
"def",
"colorsrc",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"colorsrc\"",
"]"
] | [
73,
4
] | [
84,
31
] | python | en | ['en', 'error', 'th'] | False |
Font.family | (self) |
HTML font family - the typeface that will be applied by the web
browser. The web browser will only be able to apply a font if
it is available on the system which it operates. Provide
multiple font families, separated by commas, to indicate the
preference in which to apply fonts ... |
HTML font family - the typeface that will be applied by the web
browser. The web browser will only be able to apply a font if
it is available on the system which it operates. Provide
multiple font families, separated by commas, to indicate the
preference in which to apply fonts ... | def family(self):
"""
HTML font family - the typeface that will be applied by the web
browser. The web browser will only be able to apply a font if
it is available on the system which it operates. Provide
multiple font families, separated by commas, to indicate the
prefer... | [
"def",
"family",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"family\"",
"]"
] | [
93,
4
] | [
116,
29
] | python | en | ['en', 'error', 'th'] | False |
Font.familysrc | (self) |
Sets the source reference on Chart Studio Cloud for family .
The 'familysrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
|
Sets the source reference on Chart Studio Cloud for family .
The 'familysrc' property must be specified as a string or
as a plotly.grid_objs.Column object | def familysrc(self):
"""
Sets the source reference on Chart Studio Cloud for family .
The 'familysrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
"""
return self["familysrc"] | [
"def",
"familysrc",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"familysrc\"",
"]"
] | [
125,
4
] | [
136,
32
] | python | en | ['en', 'error', 'th'] | False |
Font.size | (self) |
The 'size' property is a number and may be specified as:
- An int or float in the interval [1, inf]
- A tuple, list, or one-dimensional numpy array of the above
Returns
-------
int|float|numpy.ndarray
|
The 'size' property is a number and may be specified as:
- An int or float in the interval [1, inf]
- A tuple, list, or one-dimensional numpy array of the above | def size(self):
"""
The 'size' property is a number and may be specified as:
- An int or float in the interval [1, inf]
- A tuple, list, or one-dimensional numpy array of the above
Returns
-------
int|float|numpy.ndarray
"""
return self["size"... | [
"def",
"size",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"size\"",
"]"
] | [
145,
4
] | [
155,
27
] | python | en | ['en', 'error', 'th'] | False |
Font.sizesrc | (self) |
Sets the source reference on Chart Studio Cloud for size .
The 'sizesrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
|
Sets the source reference on Chart Studio Cloud for size .
The 'sizesrc' property must be specified as a string or
as a plotly.grid_objs.Column object | def sizesrc(self):
"""
Sets the source reference on Chart Studio Cloud for size .
The 'sizesrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
"""
return self["sizesrc"] | [
"def",
"sizesrc",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"sizesrc\"",
"]"
] | [
164,
4
] | [
175,
30
] | python | en | ['en', 'error', 'th'] | False |
Font.__init__ | (
self,
arg=None,
color=None,
colorsrc=None,
family=None,
familysrc=None,
size=None,
sizesrc=None,
**kwargs
) |
Construct a new Font object
Sets the font used in hover labels.
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.volume.hoverlabel.Font`
color
... |
Construct a new Font object
Sets the font used in hover labels. | def __init__(
self,
arg=None,
color=None,
colorsrc=None,
family=None,
familysrc=None,
size=None,
sizesrc=None,
**kwargs
):
"""
Construct a new Font object
Sets the font used in hover labels.
Parameters
... | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"color",
"=",
"None",
",",
"colorsrc",
"=",
"None",
",",
"family",
"=",
"None",
",",
"familysrc",
"=",
"None",
",",
"size",
"=",
"None",
",",
"sizesrc",
"=",
"None",
",",
"*",
"*",
"kw... | [
215,
4
] | [
329,
34
] | python | en | ['en', 'error', 'th'] | False |
SplitTeacher.observe | (self, observation) |
Process observation for metrics.
|
Process observation for metrics.
| def observe(self, observation):
"""
Process observation for metrics.
"""
if self.lastY is not None:
if self.asked_question:
self.metrics.evaluate_response(observation, self.lastY[0])
else:
self.factmetrics.evaluate_response(observat... | [
"def",
"observe",
"(",
"self",
",",
"observation",
")",
":",
"if",
"self",
".",
"lastY",
"is",
"not",
"None",
":",
"if",
"self",
".",
"asked_question",
":",
"self",
".",
"metrics",
".",
"evaluate_response",
"(",
"observation",
",",
"self",
".",
"lastY",
... | [
103,
4
] | [
113,
26
] | python | en | ['en', 'error', 'th'] | False |
mccp_compress | (protocol, data) |
Handles zlib compression, if applicable.
Args:
data (str): Incoming data to compress.
Returns:
stream (binary): Zlib-compressed data.
|
Handles zlib compression, if applicable. | def mccp_compress(protocol, data):
"""
Handles zlib compression, if applicable.
Args:
data (str): Incoming data to compress.
Returns:
stream (binary): Zlib-compressed data.
"""
if hasattr(protocol, 'zlib'):
return protocol.zlib.compress(data) + protocol.zlib.flush(FLUS... | [
"def",
"mccp_compress",
"(",
"protocol",
",",
"data",
")",
":",
"if",
"hasattr",
"(",
"protocol",
",",
"'zlib'",
")",
":",
"return",
"protocol",
".",
"zlib",
".",
"compress",
"(",
"data",
")",
"+",
"protocol",
".",
"zlib",
".",
"flush",
"(",
"FLUSH",
... | [
24,
0
] | [
37,
15
] | python | en | ['en', 'error', 'th'] | False |
Mccp.__init__ | (self, protocol) |
initialize MCCP by storing protocol on
ourselves and calling the client to see if
it supports MCCP. Sets callbacks to
start zlib compression in that case.
Args:
protocol (Protocol): The active protocol instance.
|
initialize MCCP by storing protocol on
ourselves and calling the client to see if
it supports MCCP. Sets callbacks to
start zlib compression in that case. | def __init__(self, protocol):
"""
initialize MCCP by storing protocol on
ourselves and calling the client to see if
it supports MCCP. Sets callbacks to
start zlib compression in that case.
Args:
protocol (Protocol): The active protocol instance.
"""
... | [
"def",
"__init__",
"(",
"self",
",",
"protocol",
")",
":",
"self",
".",
"protocol",
"=",
"protocol",
"self",
".",
"protocol",
".",
"protocol_flags",
"[",
"'MCCP'",
"]",
"=",
"False",
"# ask if client will mccp, connect callbacks to handle answer",
"self",
".",
"pr... | [
47,
4
] | [
62,
73
] | python | en | ['en', 'error', 'th'] | False |
Mccp.no_mccp | (self, option) |
Called if client doesn't support mccp or chooses to turn it off.
Args:
option (Option): Option dict (not used).
|
Called if client doesn't support mccp or chooses to turn it off. | def no_mccp(self, option):
"""
Called if client doesn't support mccp or chooses to turn it off.
Args:
option (Option): Option dict (not used).
"""
if hasattr(self.protocol, 'zlib'):
del self.protocol.zlib
self.protocol.protocol_flags['MCCP'] = Fa... | [
"def",
"no_mccp",
"(",
"self",
",",
"option",
")",
":",
"if",
"hasattr",
"(",
"self",
".",
"protocol",
",",
"'zlib'",
")",
":",
"del",
"self",
".",
"protocol",
".",
"zlib",
"self",
".",
"protocol",
".",
"protocol_flags",
"[",
"'MCCP'",
"]",
"=",
"Fal... | [
64,
4
] | [
75,
38
] | python | en | ['en', 'error', 'th'] | False |
Mccp.do_mccp | (self, option) |
The client supports MCCP. Set things up by
creating a zlib compression stream.
Args:
option (Option): Option dict (not used).
|
The client supports MCCP. Set things up by
creating a zlib compression stream. | def do_mccp(self, option):
"""
The client supports MCCP. Set things up by
creating a zlib compression stream.
Args:
option (Option): Option dict (not used).
"""
self.protocol.protocol_flags['MCCP'] = True
self.protocol.requestNegotiation(MCCP, '')
... | [
"def",
"do_mccp",
"(",
"self",
",",
"option",
")",
":",
"self",
".",
"protocol",
".",
"protocol_flags",
"[",
"'MCCP'",
"]",
"=",
"True",
"self",
".",
"protocol",
".",
"requestNegotiation",
"(",
"MCCP",
",",
"''",
")",
"self",
".",
"protocol",
".",
"zli... | [
77,
4
] | [
89,
38
] | python | en | ['en', 'error', 'th'] | False |
IndyIssuer.__init__ | (self, wallet) |
Initialize an IndyLedger instance.
Args:
wallet: IndyWallet instance
|
Initialize an IndyLedger instance. | def __init__(self, wallet):
"""
Initialize an IndyLedger instance.
Args:
wallet: IndyWallet instance
"""
self.logger = logging.getLogger(__name__)
self.wallet = wallet | [
"def",
"__init__",
"(",
"self",
",",
"wallet",
")",
":",
"self",
".",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"self",
".",
"wallet",
"=",
"wallet"
] | [
20,
4
] | [
29,
28
] | python | en | ['en', 'error', 'th'] | False |
IndyIssuer.create_credential_offer | (self, credential_definition_id: str) |
Create a credential offer for the given credential definition id.
Args:
credential_definition_id: The credential definition to create an offer for
Returns:
A credential offer
|
Create a credential offer for the given credential definition id. | async def create_credential_offer(self, credential_definition_id: str):
"""
Create a credential offer for the given credential definition id.
Args:
credential_definition_id: The credential definition to create an offer for
Returns:
A credential offer
""... | [
"async",
"def",
"create_credential_offer",
"(",
"self",
",",
"credential_definition_id",
":",
"str",
")",
":",
"credential_offer_json",
"=",
"await",
"indy",
".",
"anoncreds",
".",
"issuer_create_credential_offer",
"(",
"self",
".",
"wallet",
".",
"handle",
",",
"... | [
31,
4
] | [
48,
31
] | python | en | ['en', 'error', 'th'] | False |
IndyIssuer.create_credential | (
self, schema, credential_offer, credential_request, credential_values
) |
Create a credential.
Args
schema: Schema to create credential for
credential_offer: Credential Offer to create credential for
credential_request: Credential request to create credential for
credential_values: Values to go in credential
Returns:
... |
Create a credential. | async def create_credential(
self, schema, credential_offer, credential_request, credential_values
):
"""
Create a credential.
Args
schema: Schema to create credential for
credential_offer: Credential Offer to create credential for
credential_requ... | [
"async",
"def",
"create_credential",
"(",
"self",
",",
"schema",
",",
"credential_offer",
",",
"credential_request",
",",
"credential_values",
")",
":",
"encoded_values",
"=",
"{",
"}",
"schema_attributes",
"=",
"schema",
"[",
"\"attrNames\"",
"]",
"for",
"attribu... | [
50,
4
] | [
97,
68
] | python | en | ['en', 'error', 'th'] | False |
Line.color | (self) |
Sets the color of the contour level. Has no effect if
`contours.coloring` is set to "lines".
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,1... |
Sets the color of the contour level. Has no effect if
`contours.coloring` is set to "lines".
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,1... | def color(self):
"""
Sets the color of the contour level. Has no effect if
`contours.coloring` is set to "lines".
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hs... | [
"def",
"color",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"color\"",
"]"
] | [
15,
4
] | [
66,
28
] | python | en | ['en', 'error', 'th'] | False |
Line.dash | (self) |
Sets the dash style of lines. Set to a dash type string
("solid", "dot", "dash", "longdash", "dashdot", or
"longdashdot") or a dash length list in px (eg
"5px,10px,2px,2px").
The 'dash' property is an enumeration that may be specified as:
- One of the following da... |
Sets the dash style of lines. Set to a dash type string
("solid", "dot", "dash", "longdash", "dashdot", or
"longdashdot") or a dash length list in px (eg
"5px,10px,2px,2px").
The 'dash' property is an enumeration that may be specified as:
- One of the following da... | def dash(self):
"""
Sets the dash style of lines. Set to a dash type string
("solid", "dot", "dash", "longdash", "dashdot", or
"longdashdot") or a dash length list in px (eg
"5px,10px,2px,2px").
The 'dash' property is an enumeration that may be specified as:
... | [
"def",
"dash",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"dash\"",
"]"
] | [
75,
4
] | [
92,
27
] | python | en | ['en', 'error', 'th'] | False |
Line.smoothing | (self) |
Sets the amount of smoothing for the contour lines, where 0
corresponds to no smoothing.
The 'smoothing' property is a number and may be specified as:
- An int or float in the interval [0, 1.3]
Returns
-------
int|float
|
Sets the amount of smoothing for the contour lines, where 0
corresponds to no smoothing.
The 'smoothing' property is a number and may be specified as:
- An int or float in the interval [0, 1.3] | def smoothing(self):
"""
Sets the amount of smoothing for the contour lines, where 0
corresponds to no smoothing.
The 'smoothing' property is a number and may be specified as:
- An int or float in the interval [0, 1.3]
Returns
-------
int|float
... | [
"def",
"smoothing",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"smoothing\"",
"]"
] | [
101,
4
] | [
113,
32
] | python | en | ['en', 'error', 'th'] | False |
Line.width | (self) |
Sets the contour line width in (in px) Defaults to 0.5 when
`contours.type` is "levels". Defaults to 2 when `contour.type`
is "constraint".
The 'width' property is a number and may be specified as:
- An int or float in the interval [0, inf]
Returns
------... |
Sets the contour line width in (in px) Defaults to 0.5 when
`contours.type` is "levels". Defaults to 2 when `contour.type`
is "constraint".
The 'width' property is a number and may be specified as:
- An int or float in the interval [0, inf] | def width(self):
"""
Sets the contour line width in (in px) Defaults to 0.5 when
`contours.type` is "levels". Defaults to 2 when `contour.type`
is "constraint".
The 'width' property is a number and may be specified as:
- An int or float in the interval [0, inf]
... | [
"def",
"width",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"width\"",
"]"
] | [
122,
4
] | [
135,
28
] | python | en | ['en', 'error', 'th'] | False |
Line.__init__ | (
self, arg=None, color=None, dash=None, smoothing=None, width=None, **kwargs
) |
Construct a new Line object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.contourcarpet.Line`
color
Sets the color of the contour level. Has no ef... |
Construct a new Line object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.contourcarpet.Line`
color
Sets the color of the contour level. Has no ef... | def __init__(
self, arg=None, color=None, dash=None, smoothing=None, width=None, **kwargs
):
"""
Construct a new Line object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:c... | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"color",
"=",
"None",
",",
"dash",
"=",
"None",
",",
"smoothing",
"=",
"None",
",",
"width",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Line",
",",
"self",
")",
"... | [
163,
4
] | [
247,
34
] | python | en | ['en', 'error', 'th'] | False |
TimeoutUtils.get_timeout_act | (
agent: Agent,
timeout: int = DEFAULT_TIMEOUT,
quick_replies: Optional[List[str]] = None,
) |
Return an agent's act, with a specified timeout.
:param agent:
Agent who is acting
:param timeout:
how long to wait
:param quick_replies:
If given, agent's message *MUST* be one of the quick replies
:return:
An act dictionary if ... |
Return an agent's act, with a specified timeout. | def get_timeout_act(
agent: Agent,
timeout: int = DEFAULT_TIMEOUT,
quick_replies: Optional[List[str]] = None,
) -> Optional[Message]:
"""
Return an agent's act, with a specified timeout.
:param agent:
Agent who is acting
:param timeout:
... | [
"def",
"get_timeout_act",
"(",
"agent",
":",
"Agent",
",",
"timeout",
":",
"int",
"=",
"DEFAULT_TIMEOUT",
",",
"quick_replies",
":",
"Optional",
"[",
"List",
"[",
"str",
"]",
"]",
"=",
"None",
",",
")",
"->",
"Optional",
"[",
"Message",
"]",
":",
"def"... | [
21,
4
] | [
57,
18
] | python | en | ['en', 'error', 'th'] | False |
TimeoutUtils._get_response_timeout_loop | (
agent: Agent,
world: World,
timeout: int = DEFAULT_TIMEOUT,
timeout_msg: str = 'You have timed out',
) |
Get a response from the agent.
:param agent:
agent who is acting
:param world:
world in which agent is acting
:param timeout:
timeout in secs
:param timeout_msg:
what to say to agent when they timeout
:return response:
... |
Get a response from the agent. | def _get_response_timeout_loop(
agent: Agent,
world: World,
timeout: int = DEFAULT_TIMEOUT,
timeout_msg: str = 'You have timed out',
) -> Optional[Message]:
"""
Get a response from the agent.
:param agent:
agent who is acting
:param world:... | [
"def",
"_get_response_timeout_loop",
"(",
"agent",
":",
"Agent",
",",
"world",
":",
"World",
",",
"timeout",
":",
"int",
"=",
"DEFAULT_TIMEOUT",
",",
"timeout_msg",
":",
"str",
"=",
"'You have timed out'",
",",
")",
"->",
"Optional",
"[",
"Message",
"]",
":"... | [
60,
4
] | [
90,
16
] | python | en | ['en', 'error', 'th'] | False |
test_Figure | () | if the fig is not associated with a canvas, FakeRenderer shall
not fail. | if the fig is not associated with a canvas, FakeRenderer shall
not fail. | def test_Figure():
""" if the fig is not associated with a canvas, FakeRenderer shall
not fail. """
fig = plt.Figure()
ax = fig.add_subplot(111)
ax.add_patch(plt.Circle((0, 0), 1))
ax.add_patch(plt.Rectangle((0, 0), 1, 2))
_assert_output_equal(fake_renderer_output(fig, FakeRenderer),
... | [
"def",
"test_Figure",
"(",
")",
":",
"fig",
"=",
"plt",
".",
"Figure",
"(",
")",
"ax",
"=",
"fig",
".",
"add_subplot",
"(",
"111",
")",
"ax",
".",
"add_patch",
"(",
"plt",
".",
"Circle",
"(",
"(",
"0",
",",
"0",
")",
",",
"1",
")",
")",
"ax",... | [
130,
0
] | [
146,
29
] | python | en | ['en', 'en', 'en'] | True |
test_new_DID_cannot_update_another_DID | (looper,
sdk_pool_handle,
sdk_wallet_trustee,
sdk_wallet_handle) | Create trustee | Create trustee | def test_new_DID_cannot_update_another_DID(looper,
sdk_pool_handle,
sdk_wallet_trustee,
sdk_wallet_handle):
"""Create trustee"""
trustee_did, trustee_verkey = looper.loop.run_until_co... | [
"def",
"test_new_DID_cannot_update_another_DID",
"(",
"looper",
",",
"sdk_pool_handle",
",",
"sdk_wallet_trustee",
",",
"sdk_wallet_handle",
")",
":",
"trustee_did",
",",
"trustee_verkey",
"=",
"looper",
".",
"loop",
".",
"run_until_complete",
"(",
"did",
".",
"create... | [
9,
0
] | [
39,
48
] | python | en | ['et', 'ro', 'en'] | False |
Font.color | (self) |
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color:
... |
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color:
... | def color(self):
"""
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A name... | [
"def",
"color",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"color\"",
"]"
] | [
15,
4
] | [
63,
28
] | python | en | ['en', 'error', 'th'] | False |
Font.family | (self) |
HTML font family - the typeface that will be applied by the web
browser. The web browser will only be able to apply a font if
it is available on the system which it operates. Provide
multiple font families, separated by commas, to indicate the
preference in which to apply fonts ... |
HTML font family - the typeface that will be applied by the web
browser. The web browser will only be able to apply a font if
it is available on the system which it operates. Provide
multiple font families, separated by commas, to indicate the
preference in which to apply fonts ... | def family(self):
"""
HTML font family - the typeface that will be applied by the web
browser. The web browser will only be able to apply a font if
it is available on the system which it operates. Provide
multiple font families, separated by commas, to indicate the
prefer... | [
"def",
"family",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"family\"",
"]"
] | [
72,
4
] | [
94,
29
] | python | en | ['en', 'error', 'th'] | False |
Font.size | (self) |
The 'size' property is a number and may be specified as:
- An int or float in the interval [1, inf]
Returns
-------
int|float
|
The 'size' property is a number and may be specified as:
- An int or float in the interval [1, inf] | def size(self):
"""
The 'size' property is a number and may be specified as:
- An int or float in the interval [1, inf]
Returns
-------
int|float
"""
return self["size"] | [
"def",
"size",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"size\"",
"]"
] | [
103,
4
] | [
112,
27
] | python | en | ['en', 'error', 'th'] | False |
Font.__init__ | (self, arg=None, color=None, family=None, size=None, **kwargs) |
Construct a new Font object
Sets this legend's title font.
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.layout.legend.title.Font`
color
fam... |
Construct a new Font object
Sets this legend's title font. | def __init__(self, arg=None, color=None, family=None, size=None, **kwargs):
"""
Construct a new Font object
Sets this legend's title font.
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
... | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"color",
"=",
"None",
",",
"family",
"=",
"None",
",",
"size",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Font",
",",
"self",
")",
".",
"__init__",
"(",
"\"font\"",... | [
143,
4
] | [
226,
34
] | python | en | ['en', 'error', 'th'] | False |
load_json | (*path) | Convenience function to load a JSON file from DEFS_DIR. | Convenience function to load a JSON file from DEFS_DIR. | def load_json(*path):
"""Convenience function to load a JSON file from DEFS_DIR."""
if len(path) == 1 and path[0].startswith("/"):
filename = path[0]
else:
filename = os.path.join(DEFS_DIR, *path)
with open(filename) as f:
return json.load(f, object_pairs_hook=OrderedDict) | [
"def",
"load_json",
"(",
"*",
"path",
")",
":",
"if",
"len",
"(",
"path",
")",
"==",
"1",
"and",
"path",
"[",
"0",
"]",
".",
"startswith",
"(",
"\"/\"",
")",
":",
"filename",
"=",
"path",
"[",
"0",
"]",
"else",
":",
"filename",
"=",
"os",
".",
... | [
20,
0
] | [
28,
58
] | python | en | ['en', 'en', 'en'] | True |
_load_btc_coins | () | Load btc-like coins from `bitcoin/*.json` | Load btc-like coins from `bitcoin/*.json` | def _load_btc_coins():
"""Load btc-like coins from `bitcoin/*.json`"""
coins = []
for filename in glob.glob(os.path.join(DEFS_DIR, "bitcoin", "*.json")):
coin = load_json(filename)
coin.update(
name=coin["coin_label"],
shortcut=coin["coin_shortcut"],
key="... | [
"def",
"_load_btc_coins",
"(",
")",
":",
"coins",
"=",
"[",
"]",
"for",
"filename",
"in",
"glob",
".",
"glob",
"(",
"os",
".",
"path",
".",
"join",
"(",
"DEFS_DIR",
",",
"\"bitcoin\"",
",",
"\"*.json\"",
")",
")",
":",
"coin",
"=",
"load_json",
"(",
... | [
213,
0
] | [
226,
16
] | python | en | ['en', 'en', 'en'] | True |
_load_ethereum_networks | () | Load ethereum networks from `ethereum/networks.json` | Load ethereum networks from `ethereum/networks.json` | def _load_ethereum_networks():
"""Load ethereum networks from `ethereum/networks.json`"""
networks = load_json("ethereum", "networks.json")
for network in networks:
network.update(key="eth:{}".format(network["shortcut"]))
return networks | [
"def",
"_load_ethereum_networks",
"(",
")",
":",
"networks",
"=",
"load_json",
"(",
"\"ethereum\"",
",",
"\"networks.json\"",
")",
"for",
"network",
"in",
"networks",
":",
"network",
".",
"update",
"(",
"key",
"=",
"\"eth:{}\"",
".",
"format",
"(",
"network",
... | [
229,
0
] | [
234,
19
] | python | en | ['en', 'en', 'en'] | True |
_load_erc20_tokens | () | Load ERC20 tokens from `ethereum/tokens` submodule. | Load ERC20 tokens from `ethereum/tokens` submodule. | def _load_erc20_tokens():
"""Load ERC20 tokens from `ethereum/tokens` submodule."""
networks = _load_ethereum_networks()
tokens = []
for network in networks:
chain = network["chain"]
chain_path = os.path.join(DEFS_DIR, "ethereum", "tokens", "tokens", chain)
for filename in sorte... | [
"def",
"_load_erc20_tokens",
"(",
")",
":",
"networks",
"=",
"_load_ethereum_networks",
"(",
")",
"tokens",
"=",
"[",
"]",
"for",
"network",
"in",
"networks",
":",
"chain",
"=",
"network",
"[",
"\"chain\"",
"]",
"chain_path",
"=",
"os",
".",
"path",
".",
... | [
237,
0
] | [
256,
17
] | python | en | ['en', 'en', 'en'] | True |
_load_nem_mosaics | () | Loads NEM mosaics from `nem/nem_mosaics.json` | Loads NEM mosaics from `nem/nem_mosaics.json` | def _load_nem_mosaics():
"""Loads NEM mosaics from `nem/nem_mosaics.json`"""
mosaics = load_json("nem", "nem_mosaics.json")
for mosaic in mosaics:
shortcut = mosaic["ticker"].strip()
mosaic.update(shortcut=shortcut, key="nem:{}".format(shortcut))
return mosaics | [
"def",
"_load_nem_mosaics",
"(",
")",
":",
"mosaics",
"=",
"load_json",
"(",
"\"nem\"",
",",
"\"nem_mosaics.json\"",
")",
"for",
"mosaic",
"in",
"mosaics",
":",
"shortcut",
"=",
"mosaic",
"[",
"\"ticker\"",
"]",
".",
"strip",
"(",
")",
"mosaic",
".",
"upda... | [
259,
0
] | [
265,
18
] | python | en | ['en', 'fr', 'en'] | True |
_load_misc | () | Loads miscellaneous networks from `misc/misc.json` | Loads miscellaneous networks from `misc/misc.json` | def _load_misc():
"""Loads miscellaneous networks from `misc/misc.json`"""
others = load_json("misc/misc.json")
for other in others:
other.update(key="misc:{}".format(other["shortcut"]))
return others | [
"def",
"_load_misc",
"(",
")",
":",
"others",
"=",
"load_json",
"(",
"\"misc/misc.json\"",
")",
"for",
"other",
"in",
"others",
":",
"other",
".",
"update",
"(",
"key",
"=",
"\"misc:{}\"",
".",
"format",
"(",
"other",
"[",
"\"shortcut\"",
"]",
")",
")",
... | [
268,
0
] | [
273,
17
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.