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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
PolyencoderAgent.add_cmdline_args | (
cls, parser: ParlaiParser, partial_opt: Optional[Opt] = None
) |
Add command-line arguments specifically for this agent.
|
Add command-line arguments specifically for this agent.
| def add_cmdline_args(
cls, parser: ParlaiParser, partial_opt: Optional[Opt] = None
) -> ParlaiParser:
"""
Add command-line arguments specifically for this agent.
"""
TransformerRankerAgent.add_cmdline_args(parser, partial_opt=partial_opt)
agent = parser.add_argument_g... | [
"def",
"add_cmdline_args",
"(",
"cls",
",",
"parser",
":",
"ParlaiParser",
",",
"partial_opt",
":",
"Optional",
"[",
"Opt",
"]",
"=",
"None",
")",
"->",
"ParlaiParser",
":",
"TransformerRankerAgent",
".",
"add_cmdline_args",
"(",
"parser",
",",
"partial_opt",
... | [
39,
4
] | [
100,
20
] | python | en | ['en', 'error', 'th'] | False |
PolyencoderAgent.build_model | (self, states=None) |
Return built model.
|
Return built model.
| def build_model(self, states=None):
"""
Return built model.
"""
return PolyEncoderModule(self.opt, self.dict, self.NULL_IDX) | [
"def",
"build_model",
"(",
"self",
",",
"states",
"=",
"None",
")",
":",
"return",
"PolyEncoderModule",
"(",
"self",
".",
"opt",
",",
"self",
".",
"dict",
",",
"self",
".",
"NULL_IDX",
")"
] | [
129,
4
] | [
133,
68
] | python | en | ['en', 'error', 'th'] | False |
PolyencoderAgent.vectorize | (self, *args, **kwargs) |
Add the start and end token to the labels.
|
Add the start and end token to the labels.
| def vectorize(self, *args, **kwargs):
"""
Add the start and end token to the labels.
"""
kwargs['add_start'] = True
kwargs['add_end'] = True
obs = super().vectorize(*args, **kwargs)
return obs | [
"def",
"vectorize",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'add_start'",
"]",
"=",
"True",
"kwargs",
"[",
"'add_end'",
"]",
"=",
"True",
"obs",
"=",
"super",
"(",
")",
".",
"vectorize",
"(",
"*",
"args",
... | [
135,
4
] | [
142,
18
] | python | en | ['en', 'error', 'th'] | False |
PolyencoderAgent._set_text_vec | (self, *args, **kwargs) |
Add the start and end token to the text.
|
Add the start and end token to the text.
| def _set_text_vec(self, *args, **kwargs):
"""
Add the start and end token to the text.
"""
obs = super()._set_text_vec(*args, **kwargs)
if 'text_vec' in obs and 'added_start_end_tokens' not in obs:
obs.force_set(
'text_vec', self._add_start_end_tokens(... | [
"def",
"_set_text_vec",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"obs",
"=",
"super",
"(",
")",
".",
"_set_text_vec",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"if",
"'text_vec'",
"in",
"obs",
"and",
"'added_start_end_t... | [
144,
4
] | [
154,
18
] | python | en | ['en', 'error', 'th'] | False |
PolyencoderAgent.vectorize_fixed_candidates | (self, *args, **kwargs) |
Vectorize fixed candidates.
Override to add start and end token when computing the candidate encodings in
interactive mode.
|
Vectorize fixed candidates. | def vectorize_fixed_candidates(self, *args, **kwargs):
"""
Vectorize fixed candidates.
Override to add start and end token when computing the candidate encodings in
interactive mode.
"""
kwargs['add_start'] = True
kwargs['add_end'] = True
return super().v... | [
"def",
"vectorize_fixed_candidates",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'add_start'",
"]",
"=",
"True",
"kwargs",
"[",
"'add_end'",
"]",
"=",
"True",
"return",
"super",
"(",
")",
".",
"vectorize_fixed_candidat... | [
156,
4
] | [
165,
66
] | python | en | ['en', 'error', 'th'] | False |
PolyencoderAgent._make_candidate_encs | (self, vecs) |
Make candidate encs.
The polyencoder module expects cand vecs to be 3D while torch_ranker_agent
expects it to be 2D. This requires a little adjustment (used in interactive mode
only)
|
Make candidate encs. | def _make_candidate_encs(self, vecs):
"""
Make candidate encs.
The polyencoder module expects cand vecs to be 3D while torch_ranker_agent
expects it to be 2D. This requires a little adjustment (used in interactive mode
only)
"""
rep = super()._make_candidate_encs... | [
"def",
"_make_candidate_encs",
"(",
"self",
",",
"vecs",
")",
":",
"rep",
"=",
"super",
"(",
")",
".",
"_make_candidate_encs",
"(",
"vecs",
")",
"return",
"rep",
".",
"transpose",
"(",
"0",
",",
"1",
")",
".",
"contiguous",
"(",
")"
] | [
167,
4
] | [
176,
47
] | python | en | ['en', 'error', 'th'] | False |
PolyencoderAgent.encode_candidates | (self, padded_cands) |
Encode candidates.
|
Encode candidates.
| def encode_candidates(self, padded_cands):
"""
Encode candidates.
"""
padded_cands = padded_cands.unsqueeze(1)
_, _, cand_rep = self.model(cand_tokens=padded_cands)
return cand_rep | [
"def",
"encode_candidates",
"(",
"self",
",",
"padded_cands",
")",
":",
"padded_cands",
"=",
"padded_cands",
".",
"unsqueeze",
"(",
"1",
")",
"_",
",",
"_",
",",
"cand_rep",
"=",
"self",
".",
"model",
"(",
"cand_tokens",
"=",
"padded_cands",
")",
"return",... | [
178,
4
] | [
184,
23
] | python | en | ['en', 'error', 'th'] | False |
PolyencoderAgent.score_candidates | (self, batch, cand_vecs, cand_encs=None) |
Score candidates.
The Poly-encoder encodes the candidate and context independently. Then, the
model applies additional attention before ultimately scoring a candidate.
|
Score candidates. | def score_candidates(self, batch, cand_vecs, cand_encs=None):
"""
Score candidates.
The Poly-encoder encodes the candidate and context independently. Then, the
model applies additional attention before ultimately scoring a candidate.
"""
bsz = self._get_batch_size(batch)... | [
"def",
"score_candidates",
"(",
"self",
",",
"batch",
",",
"cand_vecs",
",",
"cand_encs",
"=",
"None",
")",
":",
"bsz",
"=",
"self",
".",
"_get_batch_size",
"(",
"batch",
")",
"ctxt_rep",
",",
"ctxt_rep_mask",
",",
"_",
"=",
"self",
".",
"model",
"(",
... | [
186,
4
] | [
212,
21
] | python | en | ['en', 'error', 'th'] | False |
PolyencoderAgent._get_batch_size | (self, batch) |
Return the size of the batch.
Can be overridden by subclasses that do not always have text input.
|
Return the size of the batch. | def _get_batch_size(self, batch) -> int:
"""
Return the size of the batch.
Can be overridden by subclasses that do not always have text input.
"""
return batch.text_vec.size(0) | [
"def",
"_get_batch_size",
"(",
"self",
",",
"batch",
")",
"->",
"int",
":",
"return",
"batch",
".",
"text_vec",
".",
"size",
"(",
"0",
")"
] | [
214,
4
] | [
220,
37
] | python | en | ['en', 'error', 'th'] | False |
PolyencoderAgent._model_context_input | (self, batch) |
Create the input context value for the model.
Must return a dictionary. This will be passed directly into the model via
`**kwargs`, i.e.,
>>> model(**_model_context_input(batch))
This is intentionally overridable so that richer models can pass additional
inputs.
... |
Create the input context value for the model. | def _model_context_input(self, batch) -> Dict[str, Any]:
"""
Create the input context value for the model.
Must return a dictionary. This will be passed directly into the model via
`**kwargs`, i.e.,
>>> model(**_model_context_input(batch))
This is intentionally overri... | [
"def",
"_model_context_input",
"(",
"self",
",",
"batch",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"return",
"{",
"'ctxt_tokens'",
":",
"batch",
".",
"text_vec",
"}"
] | [
222,
4
] | [
234,
46
] | python | en | ['en', 'error', 'th'] | False |
PolyencoderAgent.load_state_dict | (self, state_dict) |
Override to account for codes.
|
Override to account for codes.
| def load_state_dict(self, state_dict):
"""
Override to account for codes.
"""
if self.model.type == 'codes' and 'codes' not in state_dict:
state_dict['codes'] = self.model.codes
super().load_state_dict(state_dict) | [
"def",
"load_state_dict",
"(",
"self",
",",
"state_dict",
")",
":",
"if",
"self",
".",
"model",
".",
"type",
"==",
"'codes'",
"and",
"'codes'",
"not",
"in",
"state_dict",
":",
"state_dict",
"[",
"'codes'",
"]",
"=",
"self",
".",
"model",
".",
"codes",
... | [
236,
4
] | [
242,
43
] | python | en | ['en', 'error', 'th'] | False |
PolyencoderAgent._resize_token_embeddings | (self, state_dict, msg=None) |
Resize the token embeddings when adding extra special tokens.
H/t TransformerGenerator._resize_token_embeddings for inspiration.
|
Resize the token embeddings when adding extra special tokens. | def _resize_token_embeddings(self, state_dict, msg=None):
"""
Resize the token embeddings when adding extra special tokens.
H/t TransformerGenerator._resize_token_embeddings for inspiration.
"""
# map extra special tokens carefully
new_size = self.model.encoder_ctxt.embe... | [
"def",
"_resize_token_embeddings",
"(",
"self",
",",
"state_dict",
",",
"msg",
"=",
"None",
")",
":",
"# map extra special tokens carefully",
"new_size",
"=",
"self",
".",
"model",
".",
"encoder_ctxt",
".",
"embeddings",
".",
"weight",
".",
"size",
"(",
")",
"... | [
244,
4
] | [
271,
25
] | python | en | ['en', 'error', 'th'] | False |
PolyEncoderModule.get_encoder | (self, opt, dict_, null_idx, reduction_type, for_context: bool) |
Return encoder, given options.
:param opt:
opt dict
:param dict:
dictionary agent
:param null_idx:
null/pad index into dict
:param reduction_type:
reduction type for the encoder
:param for_context:
whether this... |
Return encoder, given options. | def get_encoder(self, opt, dict_, null_idx, reduction_type, for_context: bool):
"""
Return encoder, given options.
:param opt:
opt dict
:param dict:
dictionary agent
:param null_idx:
null/pad index into dict
:param reduction_type:
... | [
"def",
"get_encoder",
"(",
"self",
",",
"opt",
",",
"dict_",
",",
"null_idx",
",",
"reduction_type",
",",
"for_context",
":",
"bool",
")",
":",
"n_positions",
"=",
"get_n_positions_from_options",
"(",
"opt",
")",
"embeddings",
"=",
"self",
".",
"_get_embedding... | [
342,
4
] | [
383,
9
] | python | en | ['en', 'error', 'th'] | False |
PolyEncoderModule.attend | (self, attention_layer, queries, keys, values, mask) |
Apply attention.
:param attention_layer:
nn.Module attention layer to use for the attention
:param queries:
the queries for attention
:param keys:
the keys for attention
:param values:
the values for attention
:param mask:... |
Apply attention. | def attend(self, attention_layer, queries, keys, values, mask):
"""
Apply attention.
:param attention_layer:
nn.Module attention layer to use for the attention
:param queries:
the queries for attention
:param keys:
the keys for attention
... | [
"def",
"attend",
"(",
"self",
",",
"attention_layer",
",",
"queries",
",",
"keys",
",",
"values",
",",
"mask",
")",
":",
"if",
"keys",
"is",
"None",
":",
"keys",
"=",
"values",
"if",
"isinstance",
"(",
"attention_layer",
",",
"PolyBasicAttention",
")",
"... | [
392,
4
] | [
418,
61
] | python | en | ['en', 'error', 'th'] | False |
PolyEncoderModule.encode | (
self, cand_tokens: Optional[torch.Tensor], **ctxt_inputs: torch.Tensor
) |
Encode a text sequence.
:param ctxt_inputs:
Dictionary of context inputs. If not empty, should contain at least
'ctxt_tokens', a 2D long tensor of shape batchsize x sent_len
:param cand_tokens:
3D long tensor, batchsize x num_cands x sent_len
Not... |
Encode a text sequence. | def encode(
self, cand_tokens: Optional[torch.Tensor], **ctxt_inputs: torch.Tensor
) -> Tuple[Optional[torch.Tensor], Optional[torch.Tensor], Optional[torch.Tensor]]:
"""
Encode a text sequence.
:param ctxt_inputs:
Dictionary of context inputs. If not empty, should conta... | [
"def",
"encode",
"(",
"self",
",",
"cand_tokens",
":",
"Optional",
"[",
"torch",
".",
"Tensor",
"]",
",",
"*",
"*",
"ctxt_inputs",
":",
"torch",
".",
"Tensor",
")",
"->",
"Tuple",
"[",
"Optional",
"[",
"torch",
".",
"Tensor",
"]",
",",
"Optional",
"[... | [
420,
4
] | [
484,
50
] | python | en | ['en', 'error', 'th'] | False |
PolyEncoderModule._get_context_batch_size | (self, **ctxt_inputs: torch.Tensor) |
Return the batch size of the context.
Can be overridden by subclasses that do not always have text tokens in the
context.
|
Return the batch size of the context. | def _get_context_batch_size(self, **ctxt_inputs: torch.Tensor) -> int:
"""
Return the batch size of the context.
Can be overridden by subclasses that do not always have text tokens in the
context.
"""
return ctxt_inputs['ctxt_tokens'].size(0) | [
"def",
"_get_context_batch_size",
"(",
"self",
",",
"*",
"*",
"ctxt_inputs",
":",
"torch",
".",
"Tensor",
")",
"->",
"int",
":",
"return",
"ctxt_inputs",
"[",
"'ctxt_tokens'",
"]",
".",
"size",
"(",
"0",
")"
] | [
486,
4
] | [
493,
49
] | python | en | ['en', 'error', 'th'] | False |
PolyEncoderModule._context_encoder_input | (self, ctxt_inputs: Dict[str, Any]) |
Return the inputs to the context encoder as a dictionary.
Must return a dictionary. This will be passed directly into the model via
`**kwargs`, i.e.,
>>> encoder_ctxt(**_context_encoder_input(ctxt_inputs))
This is needed because the context encoder's forward function may hav... |
Return the inputs to the context encoder as a dictionary. | def _context_encoder_input(self, ctxt_inputs: Dict[str, Any]) -> Dict[str, Any]:
"""
Return the inputs to the context encoder as a dictionary.
Must return a dictionary. This will be passed directly into the model via
`**kwargs`, i.e.,
>>> encoder_ctxt(**_context_encoder_input(... | [
"def",
"_context_encoder_input",
"(",
"self",
",",
"ctxt_inputs",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"assert",
"set",
"(",
"ctxt_inputs",
".",
"keys",
"(",
")",
")",
"==",
"{",
"'ctxt_tokens... | [
495,
4
] | [
509,
52
] | python | en | ['en', 'error', 'th'] | False |
PolyEncoderModule.score | (self, ctxt_rep, ctxt_rep_mask, cand_embed) |
Score the candidates.
:param ctxt_rep:
3D float tensor, bsz x ctxt_len x dim
:param ctxt_rep_mask:
2D byte tensor, bsz x ctxt_len, in case there are some elements
of the ctxt that we should not take into account.
:param cand_embed: 3D float tensor, b... |
Score the candidates. | def score(self, ctxt_rep, ctxt_rep_mask, cand_embed):
"""
Score the candidates.
:param ctxt_rep:
3D float tensor, bsz x ctxt_len x dim
:param ctxt_rep_mask:
2D byte tensor, bsz x ctxt_len, in case there are some elements
of the ctxt that we should not... | [
"def",
"score",
"(",
"self",
",",
"ctxt_rep",
",",
"ctxt_rep_mask",
",",
"cand_embed",
")",
":",
"# reduces the context representation to a 3D tensor bsz x num_cands x dim",
"ctxt_final_rep",
"=",
"self",
".",
"attend",
"(",
"self",
".",
"attention",
",",
"cand_embed",
... | [
511,
4
] | [
529,
21
] | python | en | ['en', 'error', 'th'] | False |
PolyEncoderModule.forward | (
self,
cand_tokens=None,
ctxt_rep=None,
ctxt_rep_mask=None,
cand_rep=None,
**ctxt_inputs,
) |
Forward pass of the model.
Due to a limitation of parlai, we have to have one single model
in the agent. And because we want to be able to use data-parallel,
we need to have one single forward() method.
Therefore the operation_type can be either 'encode' or 'score'.
:p... |
Forward pass of the model. | def forward(
self,
cand_tokens=None,
ctxt_rep=None,
ctxt_rep_mask=None,
cand_rep=None,
**ctxt_inputs,
):
"""
Forward pass of the model.
Due to a limitation of parlai, we have to have one single model
in the agent. And because we want t... | [
"def",
"forward",
"(",
"self",
",",
"cand_tokens",
"=",
"None",
",",
"ctxt_rep",
"=",
"None",
",",
"ctxt_rep_mask",
"=",
"None",
",",
"cand_rep",
"=",
"None",
",",
"*",
"*",
"ctxt_inputs",
",",
")",
":",
"if",
"len",
"(",
"ctxt_inputs",
")",
">",
"0"... | [
531,
4
] | [
568,
48
] | python | en | ['en', 'error', 'th'] | False |
PolyBasicAttention.forward | (self, *args, **kwargs) |
Forward pass.
Account for accidental dimensionality reduction when num_codes is 1 and the
polyencoder type is 'codes'
|
Forward pass. | def forward(self, *args, **kwargs):
"""
Forward pass.
Account for accidental dimensionality reduction when num_codes is 1 and the
polyencoder type is 'codes'
"""
lhs_emb = super().forward(*args, **kwargs)
if self.poly_type == 'codes' and self.n_codes == 1 and len... | [
"def",
"forward",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"lhs_emb",
"=",
"super",
"(",
")",
".",
"forward",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"if",
"self",
".",
"poly_type",
"==",
"'codes'",
"and",
"self",... | [
581,
4
] | [
591,
22
] | python | en | ['en', 'error', 'th'] | False |
IRFriendlyPolyencoderAgent.add_cmdline_args | (
cls, parser: ParlaiParser, partial_opt: Optional[Opt] = None
) |
Add cmd line args.
|
Add cmd line args.
| def add_cmdline_args(
cls, parser: ParlaiParser, partial_opt: Optional[Opt] = None
) -> ParlaiParser:
"""
Add cmd line args.
"""
AddLabelFixedCandsTRA.add_cmdline_args(parser, partial_opt=partial_opt)
PolyencoderAgent.add_cmdline_args(parser, partial_opt=partial_opt)
... | [
"def",
"add_cmdline_args",
"(",
"cls",
",",
"parser",
":",
"ParlaiParser",
",",
"partial_opt",
":",
"Optional",
"[",
"Opt",
"]",
"=",
"None",
")",
"->",
"ParlaiParser",
":",
"AddLabelFixedCandsTRA",
".",
"add_cmdline_args",
"(",
"parser",
",",
"partial_opt",
"... | [
600,
4
] | [
608,
21
] | python | en | ['en', 'error', 'th'] | False |
PresentationAckHandler.handle | (self, context: RequestContext, responder: BaseResponder) |
Message handler logic for presentation acks.
Args:
context: request context
responder: responder callback
|
Message handler logic for presentation acks. | async def handle(self, context: RequestContext, responder: BaseResponder):
"""
Message handler logic for presentation acks.
Args:
context: request context
responder: responder callback
"""
self._logger.debug("PresentationAckHandler called with context %s"... | [
"async",
"def",
"handle",
"(",
"self",
",",
"context",
":",
"RequestContext",
",",
"responder",
":",
"BaseResponder",
")",
":",
"self",
".",
"_logger",
".",
"debug",
"(",
"\"PresentationAckHandler called with context %s\"",
",",
"context",
")",
"assert",
"isinstan... | [
16,
4
] | [
35,
61
] | python | en | ['en', 'error', 'th'] | False |
setup_args | (parser=None) |
Build the ParlAI parser, adding command line args if necessary.
:param ParlaiParser parser:
Preexisting parser to append options to. Will be created if needed.
:returns:
the ParlaiParser with CLI options added.
|
Build the ParlAI parser, adding command line args if necessary. | def setup_args(parser=None) -> ParlaiParser:
"""
Build the ParlAI parser, adding command line args if necessary.
:param ParlaiParser parser:
Preexisting parser to append options to. Will be created if needed.
:returns:
the ParlaiParser with CLI options added.
"""
if parser is N... | [
"def",
"setup_args",
"(",
"parser",
"=",
"None",
")",
"->",
"ParlaiParser",
":",
"if",
"parser",
"is",
"None",
":",
"parser",
"=",
"ParlaiParser",
"(",
"True",
",",
"True",
",",
"'Train a model'",
")",
"train",
"=",
"parser",
".",
"add_argument_group",
"("... | [
56,
0
] | [
212,
17
] | python | en | ['en', 'error', 'th'] | False |
load_eval_worlds | (agent, opt, datatype) |
Create a new eval world for the agent and the given opt.
Overrides the datatype options for doing this. Handles some magic
overrides of other special options for the training script.
:param Agent agent:
The model being trained.
:param Opt opt:
The global CLI opts.
:param st... |
Create a new eval world for the agent and the given opt. | def load_eval_worlds(agent, opt, datatype):
"""
Create a new eval world for the agent and the given opt.
Overrides the datatype options for doing this. Handles some magic
overrides of other special options for the training script.
:param Agent agent:
The model being trained.
:param O... | [
"def",
"load_eval_worlds",
"(",
"agent",
",",
"opt",
",",
"datatype",
")",
":",
"if",
"'stream'",
"in",
"opt",
"[",
"'datatype'",
"]",
":",
"datatype",
"+=",
"':stream'",
"opt",
"=",
"opt",
".",
"copy",
"(",
")",
"opt",
"[",
"'datatype'",
"]",
"=",
"... | [
215,
0
] | [
266,
17
] | python | en | ['en', 'error', 'th'] | False |
TrainLoop.save_model | (self, suffix=None) |
Save the model to disk, possibly with a suffix.
|
Save the model to disk, possibly with a suffix.
| def save_model(self, suffix=None):
"""
Save the model to disk, possibly with a suffix.
"""
if not is_primary_worker():
# never do IO as a non-primary worker
return
if not self.opt.get('model_file'):
# nothing to save to, just exit
... | [
"def",
"save_model",
"(",
"self",
",",
"suffix",
"=",
"None",
")",
":",
"if",
"not",
"is_primary_worker",
"(",
")",
":",
"# never do IO as a non-primary worker",
"return",
"if",
"not",
"self",
".",
"opt",
".",
"get",
"(",
"'model_file'",
")",
":",
"# nothing... | [
385,
4
] | [
407,
20
] | python | en | ['en', 'error', 'th'] | False |
TrainLoop.validate | (self) |
Perform a validation run, checking whether we should stop training.
:return: boolean indicating whether training should stop
:rtype: bool
|
Perform a validation run, checking whether we should stop training. | def validate(self):
"""
Perform a validation run, checking whether we should stop training.
:return: boolean indicating whether training should stop
:rtype: bool
"""
opt = self.opt
if self.valid_worlds is None:
# we need to load the world now
... | [
"def",
"validate",
"(",
"self",
")",
":",
"opt",
"=",
"self",
".",
"opt",
"if",
"self",
".",
"valid_worlds",
"is",
"None",
":",
"# we need to load the world now",
"self",
".",
"valid_worlds",
"=",
"load_eval_worlds",
"(",
"self",
".",
"agent",
",",
"opt",
... | [
428,
4
] | [
521,
20
] | python | en | ['en', 'error', 'th'] | False |
TrainLoop._run_eval | (self, valid_worlds, opt, datatype, max_exs=-1, write_log=False) |
Eval on validation/test data.
:param valid_world:
list of the pre-created validation worlds.
:param opt:
the options that specific the task, eval_task, etc
:param datatype:
the datatype to use, such as "valid" or "test"
:param bool write_log:... |
Eval on validation/test data. | def _run_eval(self, valid_worlds, opt, datatype, max_exs=-1, write_log=False):
"""
Eval on validation/test data.
:param valid_world:
list of the pre-created validation worlds.
:param opt:
the options that specific the task, eval_task, etc
:param datatype:... | [
"def",
"_run_eval",
"(",
"self",
",",
"valid_worlds",
",",
"opt",
",",
"datatype",
",",
"max_exs",
"=",
"-",
"1",
",",
"write_log",
"=",
"False",
")",
":",
"logging",
".",
"info",
"(",
"f'running eval: {datatype}'",
")",
"timer",
"=",
"Timer",
"(",
")",
... | [
543,
4
] | [
586,
21
] | python | en | ['en', 'error', 'th'] | False |
TrainLoop._sync_metrics | (self, metrics) |
Sync training metrics across workers.
A handful of special cases are handled as exceptions, and the remaining metrics
are simply averaged across workers.
|
Sync training metrics across workers. | def _sync_metrics(self, metrics):
"""
Sync training metrics across workers.
A handful of special cases are handled as exceptions, and the remaining metrics
are simply averaged across workers.
"""
if not is_distributed():
# nothing special needed
r... | [
"def",
"_sync_metrics",
"(",
"self",
",",
"metrics",
")",
":",
"if",
"not",
"is_distributed",
"(",
")",
":",
"# nothing special needed",
"return",
"metrics",
"all_versions",
"=",
"all_gather_list",
"(",
"metrics",
")",
"return",
"aggregate_unnamed_reports",
"(",
"... | [
588,
4
] | [
599,
54
] | python | en | ['en', 'error', 'th'] | False |
TrainLoop._compute_eta | (self, epochs_completed, time_elapsed) |
Compute the estimated seconds remaining in training.
:param float epochs_completed: number of epochs already completed.
:param float time_elapsed: total time spent already, in seconds.
:return: ETA in seconds, or None if not computable
|
Compute the estimated seconds remaining in training. | def _compute_eta(self, epochs_completed, time_elapsed):
"""
Compute the estimated seconds remaining in training.
:param float epochs_completed: number of epochs already completed.
:param float time_elapsed: total time spent already, in seconds.
:return: ETA in seconds, or None i... | [
"def",
"_compute_eta",
"(",
"self",
",",
"epochs_completed",
",",
"time_elapsed",
")",
":",
"# start off with no estimate",
"eta",
"=",
"None",
"# Determine time_left and num_epochs",
"max_epochs",
"=",
"self",
".",
"opt",
".",
"get",
"(",
"'num_epochs'",
",",
"0",
... | [
601,
4
] | [
624,
18
] | python | en | ['en', 'error', 'th'] | False |
TrainLoop.log | (self) |
Output a training log entry.
|
Output a training log entry.
| def log(self):
"""
Output a training log entry.
"""
opt = self.opt
if opt['display_examples']:
print(self.world.display() + '\n~~')
logs = []
# get report
train_report = self.world.report()
train_report = self._sync_metrics(train_report... | [
"def",
"log",
"(",
"self",
")",
":",
"opt",
"=",
"self",
".",
"opt",
"if",
"opt",
"[",
"'display_examples'",
"]",
":",
"print",
"(",
"self",
".",
"world",
".",
"display",
"(",
")",
"+",
"'\\n~~'",
")",
"logs",
"=",
"[",
"]",
"# get report",
"train_... | [
626,
4
] | [
663,
75
] | python | en | ['en', 'error', 'th'] | False |
TrainLoop.train | (self) |
Perform a training run.
:return: tuple of reports (validation_report, test_report)
|
Perform a training run. | def train(self):
"""
Perform a training run.
:return: tuple of reports (validation_report, test_report)
"""
logging.info('training...')
opt = self.opt
world = self.world
with world:
while True:
# do one example / batch of examp... | [
"def",
"train",
"(",
"self",
")",
":",
"logging",
".",
"info",
"(",
"'training...'",
")",
"opt",
"=",
"self",
".",
"opt",
"world",
"=",
"self",
".",
"world",
"with",
"world",
":",
"while",
"True",
":",
"# do one example / batch of examples",
"try",
":",
... | [
665,
4
] | [
777,
33
] | python | en | ['en', 'error', 'th'] | False |
get_classes | (dataset) | Get class names of a dataset. | Get class names of a dataset. | def get_classes(dataset):
"""Get class names of a dataset."""
alias2name = {}
for name, aliases in dataset_aliases.items():
for alias in aliases:
alias2name[alias] = name
if mmcv.is_str(dataset):
if dataset in alias2name:
labels = eval(alias2name[dataset] + '_cla... | [
"def",
"get_classes",
"(",
"dataset",
")",
":",
"alias2name",
"=",
"{",
"}",
"for",
"name",
",",
"aliases",
"in",
"dataset_aliases",
".",
"items",
"(",
")",
":",
"for",
"alias",
"in",
"aliases",
":",
"alias2name",
"[",
"alias",
"]",
"=",
"name",
"if",
... | [
101,
0
] | [
115,
17
] | python | en | ['en', 'su', 'en'] | True |
Line.autocolorscale | (self) |
Determines whether the colorscale is a default palette
(`autocolorscale: true`) or the palette determined by
`marker.line.colorscale`. Has an effect only if in
`marker.line.color`is set to a numerical array. In case
`colorscale` is unspecified or `autocolorscale` is true, the
... |
Determines whether the colorscale is a default palette
(`autocolorscale: true`) or the palette determined by
`marker.line.colorscale`. Has an effect only if in
`marker.line.color`is set to a numerical array. In case
`colorscale` is unspecified or `autocolorscale` is true, the
... | def autocolorscale(self):
"""
Determines whether the colorscale is a default palette
(`autocolorscale: true`) or the palette determined by
`marker.line.colorscale`. Has an effect only if in
`marker.line.color`is set to a numerical array. In case
`colorscale` is unspecifie... | [
"def",
"autocolorscale",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"autocolorscale\"",
"]"
] | [
28,
4
] | [
45,
37
] | python | en | ['en', 'error', 'th'] | False |
Line.cauto | (self) |
Determines whether or not the color domain is computed with
respect to the input data (here in `marker.line.color`) or the
bounds set in `marker.line.cmin` and `marker.line.cmax` Has an
effect only if in `marker.line.color`is set to a numerical
array. Defaults to `false` when `... |
Determines whether or not the color domain is computed with
respect to the input data (here in `marker.line.color`) or the
bounds set in `marker.line.cmin` and `marker.line.cmax` Has an
effect only if in `marker.line.color`is set to a numerical
array. Defaults to `false` when `... | def cauto(self):
"""
Determines whether or not the color domain is computed with
respect to the input data (here in `marker.line.color`) or the
bounds set in `marker.line.cmin` and `marker.line.cmax` Has an
effect only if in `marker.line.color`is set to a numerical
array... | [
"def",
"cauto",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"cauto\"",
"]"
] | [
54,
4
] | [
70,
28
] | python | en | ['en', 'error', 'th'] | False |
Line.cmax | (self) |
Sets the upper bound of the color domain. Has an effect only if
in `marker.line.color`is set to a numerical array. Value should
have the same units as in `marker.line.color` and if set,
`marker.line.cmin` must be set as well.
The 'cmax' property is a number and may be speci... |
Sets the upper bound of the color domain. Has an effect only if
in `marker.line.color`is set to a numerical array. Value should
have the same units as in `marker.line.color` and if set,
`marker.line.cmin` must be set as well.
The 'cmax' property is a number and may be speci... | def cmax(self):
"""
Sets the upper bound of the color domain. Has an effect only if
in `marker.line.color`is set to a numerical array. Value should
have the same units as in `marker.line.color` and if set,
`marker.line.cmin` must be set as well.
The 'cmax' property i... | [
"def",
"cmax",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"cmax\"",
"]"
] | [
79,
4
] | [
93,
27
] | python | en | ['en', 'error', 'th'] | False |
Line.cmid | (self) |
Sets the mid-point of the color domain by scaling
`marker.line.cmin` and/or `marker.line.cmax` to be equidistant
to this point. Has an effect only if in `marker.line.color`is
set to a numerical array. Value should have the same units as
in `marker.line.color`. Has no effect when... |
Sets the mid-point of the color domain by scaling
`marker.line.cmin` and/or `marker.line.cmax` to be equidistant
to this point. Has an effect only if in `marker.line.color`is
set to a numerical array. Value should have the same units as
in `marker.line.color`. Has no effect when... | def cmid(self):
"""
Sets the mid-point of the color domain by scaling
`marker.line.cmin` and/or `marker.line.cmax` to be equidistant
to this point. Has an effect only if in `marker.line.color`is
set to a numerical array. Value should have the same units as
in `marker.line... | [
"def",
"cmid",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"cmid\"",
"]"
] | [
102,
4
] | [
118,
27
] | python | en | ['en', 'error', 'th'] | False |
Line.cmin | (self) |
Sets the lower bound of the color domain. Has an effect only if
in `marker.line.color`is set to a numerical array. Value should
have the same units as in `marker.line.color` and if set,
`marker.line.cmax` must be set as well.
The 'cmin' property is a number and may be speci... |
Sets the lower bound of the color domain. Has an effect only if
in `marker.line.color`is set to a numerical array. Value should
have the same units as in `marker.line.color` and if set,
`marker.line.cmax` must be set as well.
The 'cmin' property is a number and may be speci... | def cmin(self):
"""
Sets the lower bound of the color domain. Has an effect only if
in `marker.line.color`is set to a numerical array. Value should
have the same units as in `marker.line.color` and if set,
`marker.line.cmax` must be set as well.
The 'cmin' property i... | [
"def",
"cmin",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"cmin\"",
"]"
] | [
127,
4
] | [
141,
27
] | python | en | ['en', 'error', 'th'] | False |
Line.color | (self) |
Sets themarker.linecolor. It accepts either a specific color or
an array of numbers that are mapped to the colorscale relative
to the max and min values of the array or relative to
`marker.line.cmin` and `marker.line.cmax` if set.
The 'color' property is a color and may be ... |
Sets themarker.linecolor. It accepts either a specific color or
an array of numbers that are mapped to the colorscale relative
to the max and min values of the array or relative to
`marker.line.cmin` and `marker.line.cmax` if set.
The 'color' property is a color and may be ... | def color(self):
"""
Sets themarker.linecolor. It accepts either a specific color or
an array of numbers that are mapped to the colorscale relative
to the max and min values of the array or relative to
`marker.line.cmin` and `marker.line.cmax` if set.
The 'color' pro... | [
"def",
"color",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"color\"",
"]"
] | [
150,
4
] | [
206,
28
] | python | en | ['en', 'error', 'th'] | False |
Line.coloraxis | (self) |
Sets a reference to a shared color axis. References to these
shared color axes are "coloraxis", "coloraxis2", "coloraxis3",
etc. Settings for these shared color axes are set in the
layout, under `layout.coloraxis`, `layout.coloraxis2`, etc.
Note that multiple color scales can be... |
Sets a reference to a shared color axis. References to these
shared color axes are "coloraxis", "coloraxis2", "coloraxis3",
etc. Settings for these shared color axes are set in the
layout, under `layout.coloraxis`, `layout.coloraxis2`, etc.
Note that multiple color scales can be... | def coloraxis(self):
"""
Sets a reference to a shared color axis. References to these
shared color axes are "coloraxis", "coloraxis2", "coloraxis3",
etc. Settings for these shared color axes are set in the
layout, under `layout.coloraxis`, `layout.coloraxis2`, etc.
Note t... | [
"def",
"coloraxis",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"coloraxis\"",
"]"
] | [
215,
4
] | [
233,
32
] | python | en | ['en', 'error', 'th'] | False |
Line.colorscale | (self) |
Sets the colorscale. Has an effect only if in
`marker.line.color`is set to a numerical array. The colorscale
must be an array containing arrays mapping a normalized value
to an rgb, rgba, hex, hsl, hsv, or named color string. At
minimum, a mapping for the lowest (0) and highest ... |
Sets the colorscale. Has an effect only if in
`marker.line.color`is set to a numerical array. The colorscale
must be an array containing arrays mapping a normalized value
to an rgb, rgba, hex, hsl, hsv, or named color string. At
minimum, a mapping for the lowest (0) and highest ... | def colorscale(self):
"""
Sets the colorscale. Has an effect only if in
`marker.line.color`is set to a numerical array. The colorscale
must be an array containing arrays mapping a normalized value
to an rgb, rgba, hex, hsl, hsv, or named color string. At
minimum, a mappin... | [
"def",
"colorscale",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"colorscale\"",
"]"
] | [
242,
4
] | [
287,
33
] | python | en | ['en', 'error', 'th'] | False |
Line.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\"",
"]"
] | [
296,
4
] | [
307,
31
] | python | en | ['en', 'error', 'th'] | False |
Line.reversescale | (self) |
Reverses the color mapping if true. Has an effect only if in
`marker.line.color`is set to a numerical array. If true,
`marker.line.cmin` will correspond to the last color in the
array and `marker.line.cmax` will correspond to the first
color.
The 'reversescale' prop... |
Reverses the color mapping if true. Has an effect only if in
`marker.line.color`is set to a numerical array. If true,
`marker.line.cmin` will correspond to the last color in the
array and `marker.line.cmax` will correspond to the first
color.
The 'reversescale' prop... | def reversescale(self):
"""
Reverses the color mapping if true. Has an effect only if in
`marker.line.color`is set to a numerical array. If true,
`marker.line.cmin` will correspond to the last color in the
array and `marker.line.cmax` will correspond to the first
color.
... | [
"def",
"reversescale",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"reversescale\"",
"]"
] | [
316,
4
] | [
331,
35
] | python | en | ['en', 'error', 'th'] | False |
Line.width | (self) |
Sets the width (in px) of the lines bounding the marker points.
The 'width' property is a number and may be specified as:
- An int or float in the interval [0, inf]
- A tuple, list, or one-dimensional numpy array of the above
Returns
-------
int|float|n... |
Sets the width (in px) of the lines bounding the marker points.
The 'width' property is a number and may be specified as:
- An int or float in the interval [0, inf]
- A tuple, list, or one-dimensional numpy array of the above | def width(self):
"""
Sets the width (in px) of the lines bounding the marker points.
The 'width' property is a number and may be specified as:
- An int or float in the interval [0, inf]
- A tuple, list, or one-dimensional numpy array of the above
Returns
... | [
"def",
"width",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"width\"",
"]"
] | [
340,
4
] | [
352,
28
] | python | en | ['en', 'error', 'th'] | False |
Line.widthsrc | (self) |
Sets the source reference on Chart Studio Cloud for width .
The 'widthsrc' 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 width .
The 'widthsrc' property must be specified as a string or
as a plotly.grid_objs.Column object | def widthsrc(self):
"""
Sets the source reference on Chart Studio Cloud for width .
The 'widthsrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
"""
return self["widthsrc"] | [
"def",
"widthsrc",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"widthsrc\"",
"]"
] | [
361,
4
] | [
372,
31
] | python | en | ['en', 'error', 'th'] | False |
Line.__init__ | (
self,
arg=None,
autocolorscale=None,
cauto=None,
cmax=None,
cmid=None,
cmin=None,
color=None,
coloraxis=None,
colorscale=None,
colorsrc=None,
reversescale=None,
width=None,
widthsrc=None,
**kwargs
... |
Construct a new Line object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.splom.marker.Line`
autocolorscale
Determines whether the colorscale is a... |
Construct a new Line object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.splom.marker.Line`
autocolorscale
Determines whether the colorscale is a... | def __init__(
self,
arg=None,
autocolorscale=None,
cauto=None,
cmax=None,
cmid=None,
cmin=None,
color=None,
coloraxis=None,
colorscale=None,
colorsrc=None,
reversescale=None,
width=None,
widthsrc=None,
... | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"autocolorscale",
"=",
"None",
",",
"cauto",
"=",
"None",
",",
"cmax",
"=",
"None",
",",
"cmid",
"=",
"None",
",",
"cmin",
"=",
"None",
",",
"color",
"=",
"None",
",",
"coloraxis",
"=",
... | [
464,
4
] | [
658,
34
] | python | en | ['en', 'error', 'th'] | False |
create | (body) |
Create a new folder.
:param (dict) body: A mapping of body param names to values.
:returns: (requests.Response) Returns response directly from requests.
|
Create a new folder. | def create(body):
"""
Create a new folder.
:param (dict) body: A mapping of body param names to values.
:returns: (requests.Response) Returns response directly from requests.
"""
url = build_url(RESOURCE)
return request("post", url, json=body) | [
"def",
"create",
"(",
"body",
")",
":",
"url",
"=",
"build_url",
"(",
"RESOURCE",
")",
"return",
"request",
"(",
"\"post\"",
",",
"url",
",",
"json",
"=",
"body",
")"
] | [
8,
0
] | [
17,
42
] | python | en | ['en', 'error', 'th'] | False |
retrieve | (fid, share_key=None) |
Retrieve a folder from Plotly.
:param (str) fid: The `{username}:{idlocal}` identifier. E.g. `foo:88`.
:param (str) share_key: The secret key granting 'read' access if private.
:returns: (requests.Response) Returns response directly from requests.
|
Retrieve a folder from Plotly. | def retrieve(fid, share_key=None):
"""
Retrieve a folder from Plotly.
:param (str) fid: The `{username}:{idlocal}` identifier. E.g. `foo:88`.
:param (str) share_key: The secret key granting 'read' access if private.
:returns: (requests.Response) Returns response directly from requests.
"""
... | [
"def",
"retrieve",
"(",
"fid",
",",
"share_key",
"=",
"None",
")",
":",
"url",
"=",
"build_url",
"(",
"RESOURCE",
",",
"id",
"=",
"fid",
")",
"params",
"=",
"make_params",
"(",
"share_key",
"=",
"share_key",
")",
"return",
"request",
"(",
"\"get\"",
",... | [
20,
0
] | [
31,
45
] | python | en | ['en', 'error', 'th'] | False |
update | (fid, body) |
Update a folder from Plotly.
:param (str) fid: The `{username}:{idlocal}` identifier. E.g. `foo:88`.
:param (dict) body: A mapping of body param names to values.
:returns: (requests.Response) Returns response directly from requests.
|
Update a folder from Plotly. | def update(fid, body):
"""
Update a folder from Plotly.
:param (str) fid: The `{username}:{idlocal}` identifier. E.g. `foo:88`.
:param (dict) body: A mapping of body param names to values.
:returns: (requests.Response) Returns response directly from requests.
"""
url = build_url(RESOURCE, ... | [
"def",
"update",
"(",
"fid",
",",
"body",
")",
":",
"url",
"=",
"build_url",
"(",
"RESOURCE",
",",
"id",
"=",
"fid",
")",
"return",
"request",
"(",
"\"put\"",
",",
"url",
",",
"json",
"=",
"body",
")"
] | [
34,
0
] | [
44,
41
] | python | en | ['en', 'error', 'th'] | False |
trash | (fid) |
Soft-delete a folder from Plotly. (Can be undone with 'restore').
This action is recursively done on files inside the folder.
:param (str) fid: The `{username}:{idlocal}` identifier. E.g. `foo:88`.
:returns: (requests.Response) Returns response directly from requests.
|
Soft-delete a folder from Plotly. (Can be undone with 'restore'). | def trash(fid):
"""
Soft-delete a folder from Plotly. (Can be undone with 'restore').
This action is recursively done on files inside the folder.
:param (str) fid: The `{username}:{idlocal}` identifier. E.g. `foo:88`.
:returns: (requests.Response) Returns response directly from requests.
"""
... | [
"def",
"trash",
"(",
"fid",
")",
":",
"url",
"=",
"build_url",
"(",
"RESOURCE",
",",
"id",
"=",
"fid",
",",
"route",
"=",
"\"trash\"",
")",
"return",
"request",
"(",
"\"post\"",
",",
"url",
")"
] | [
47,
0
] | [
58,
31
] | python | en | ['en', 'error', 'th'] | False |
restore | (fid) |
Restore a trashed folder from Plotly. See 'trash'.
This action is recursively done on files inside the folder.
:param (str) fid: The `{username}:{idlocal}` identifier. E.g. `foo:88`.
:returns: (requests.Response) Returns response directly from requests.
|
Restore a trashed folder from Plotly. See 'trash'. | def restore(fid):
"""
Restore a trashed folder from Plotly. See 'trash'.
This action is recursively done on files inside the folder.
:param (str) fid: The `{username}:{idlocal}` identifier. E.g. `foo:88`.
:returns: (requests.Response) Returns response directly from requests.
"""
url = bui... | [
"def",
"restore",
"(",
"fid",
")",
":",
"url",
"=",
"build_url",
"(",
"RESOURCE",
",",
"id",
"=",
"fid",
",",
"route",
"=",
"\"restore\"",
")",
"return",
"request",
"(",
"\"post\"",
",",
"url",
")"
] | [
61,
0
] | [
72,
31
] | python | en | ['en', 'error', 'th'] | False |
permanent_delete | (fid) |
Permanently delete a trashed folder file from Plotly. See 'trash'.
This action is recursively done on files inside the folder.
:param (str) fid: The `{username}:{idlocal}` identifier. E.g. `foo:88`.
:returns: (requests.Response) Returns response directly from requests.
|
Permanently delete a trashed folder file from Plotly. See 'trash'. | def permanent_delete(fid):
"""
Permanently delete a trashed folder file from Plotly. See 'trash'.
This action is recursively done on files inside the folder.
:param (str) fid: The `{username}:{idlocal}` identifier. E.g. `foo:88`.
:returns: (requests.Response) Returns response directly from request... | [
"def",
"permanent_delete",
"(",
"fid",
")",
":",
"url",
"=",
"build_url",
"(",
"RESOURCE",
",",
"id",
"=",
"fid",
",",
"route",
"=",
"\"permanent_delete\"",
")",
"return",
"request",
"(",
"\"delete\"",
",",
"url",
")"
] | [
75,
0
] | [
86,
33
] | python | en | ['en', 'error', 'th'] | False |
lookup | (path, parent=None, user=None, exists=None) |
Retrieve a folder file from Plotly without needing a fid.
:param (str) path: The '/'-delimited path specifying the file location.
:param (int) parent: Parent id, an integer, which the path is relative to.
:param (str) user: The username to target files for. Defaults to requestor.
:param (bool) exi... |
Retrieve a folder file from Plotly without needing a fid. | def lookup(path, parent=None, user=None, exists=None):
"""
Retrieve a folder file from Plotly without needing a fid.
:param (str) path: The '/'-delimited path specifying the file location.
:param (int) parent: Parent id, an integer, which the path is relative to.
:param (str) user: The username to ... | [
"def",
"lookup",
"(",
"path",
",",
"parent",
"=",
"None",
",",
"user",
"=",
"None",
",",
"exists",
"=",
"None",
")",
":",
"url",
"=",
"build_url",
"(",
"RESOURCE",
",",
"route",
"=",
"\"lookup\"",
")",
"params",
"=",
"make_params",
"(",
"path",
"=",
... | [
89,
0
] | [
102,
45
] | python | en | ['en', 'error', 'th'] | False |
Textfont.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 |
Textfont.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 |
Textfont.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 |
Textfont.__init__ | (self, arg=None, color=None, family=None, size=None, **kwargs) |
Construct a new Textfont object
Sets the icon text font (color=mapbox.layer.paint.text-color,
size=mapbox.layer.layout.text-size). Has an effect only when
`type` is set to "symbol".
Parameters
----------
arg
dict of properties compatible wit... |
Construct a new Textfont object
Sets the icon text font (color=mapbox.layer.paint.text-color,
size=mapbox.layer.layout.text-size). Has an effect only when
`type` is set to "symbol". | def __init__(self, arg=None, color=None, family=None, size=None, **kwargs):
"""
Construct a new Textfont object
Sets the icon text font (color=mapbox.layer.paint.text-color,
size=mapbox.layer.layout.text-size). Has an effect only when
`type` is set to "symbol".
... | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"color",
"=",
"None",
",",
"family",
"=",
"None",
",",
"size",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Textfont",
",",
"self",
")",
".",
"__init__",
"(",
"\"text... | [
143,
4
] | [
228,
34
] | python | en | ['en', 'error', 'th'] | False |
Lataxis.dtick | (self) |
Sets the graticule's longitude/latitude tick step.
The 'dtick' property is a number and may be specified as:
- An int or float
Returns
-------
int|float
|
Sets the graticule's longitude/latitude tick step.
The 'dtick' property is a number and may be specified as:
- An int or float | def dtick(self):
"""
Sets the graticule's longitude/latitude tick step.
The 'dtick' property is a number and may be specified as:
- An int or float
Returns
-------
int|float
"""
return self["dtick"] | [
"def",
"dtick",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"dtick\"",
"]"
] | [
15,
4
] | [
26,
28
] | python | en | ['en', 'error', 'th'] | False |
Lataxis.gridcolor | (self) |
Sets the graticule's stroke color.
The 'gridcolor' 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%,10... |
Sets the graticule's stroke color.
The 'gridcolor' 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%,10... | def gridcolor(self):
"""
Sets the graticule's stroke color.
The 'gridcolor' 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/... | [
"def",
"gridcolor",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"gridcolor\"",
"]"
] | [
35,
4
] | [
85,
32
] | python | en | ['en', 'error', 'th'] | False |
Lataxis.gridwidth | (self) |
Sets the graticule's stroke width (in px).
The 'gridwidth' property is a number and may be specified as:
- An int or float in the interval [0, inf]
Returns
-------
int|float
|
Sets the graticule's stroke width (in px).
The 'gridwidth' property is a number and may be specified as:
- An int or float in the interval [0, inf] | def gridwidth(self):
"""
Sets the graticule's stroke width (in px).
The 'gridwidth' property is a number and may be specified as:
- An int or float in the interval [0, inf]
Returns
-------
int|float
"""
return self["gridwidth"] | [
"def",
"gridwidth",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"gridwidth\"",
"]"
] | [
94,
4
] | [
105,
32
] | python | en | ['en', 'error', 'th'] | False |
Lataxis.range | (self) |
Sets the range of this axis (in degrees), sets the map's
clipped coordinates.
The 'range' property is an info array that may be specified as:
* a list or tuple of 2 elements where:
(0) The 'range[0]' property is a number and may be specified as:
- An int or float... |
Sets the range of this axis (in degrees), sets the map's
clipped coordinates.
The 'range' property is an info array that may be specified as:
* a list or tuple of 2 elements where:
(0) The 'range[0]' property is a number and may be specified as:
- An int or float... | def range(self):
"""
Sets the range of this axis (in degrees), sets the map's
clipped coordinates.
The 'range' property is an info array that may be specified as:
* a list or tuple of 2 elements where:
(0) The 'range[0]' property is a number and may be specified as:... | [
"def",
"range",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"range\"",
"]"
] | [
114,
4
] | [
131,
28
] | python | en | ['en', 'error', 'th'] | False |
Lataxis.showgrid | (self) |
Sets whether or not graticule are shown on the map.
The 'showgrid' property must be specified as a bool
(either True, or False)
Returns
-------
bool
|
Sets whether or not graticule are shown on the map.
The 'showgrid' property must be specified as a bool
(either True, or False) | def showgrid(self):
"""
Sets whether or not graticule are shown on the map.
The 'showgrid' property must be specified as a bool
(either True, or False)
Returns
-------
bool
"""
return self["showgrid"] | [
"def",
"showgrid",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"showgrid\"",
"]"
] | [
140,
4
] | [
151,
31
] | python | en | ['en', 'error', 'th'] | False |
Lataxis.tick0 | (self) |
Sets the graticule's starting tick longitude/latitude.
The 'tick0' property is a number and may be specified as:
- An int or float
Returns
-------
int|float
|
Sets the graticule's starting tick longitude/latitude.
The 'tick0' property is a number and may be specified as:
- An int or float | def tick0(self):
"""
Sets the graticule's starting tick longitude/latitude.
The 'tick0' property is a number and may be specified as:
- An int or float
Returns
-------
int|float
"""
return self["tick0"] | [
"def",
"tick0",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"tick0\"",
"]"
] | [
160,
4
] | [
171,
28
] | python | en | ['en', 'error', 'th'] | False |
Lataxis.__init__ | (
self,
arg=None,
dtick=None,
gridcolor=None,
gridwidth=None,
range=None,
showgrid=None,
tick0=None,
**kwargs
) |
Construct a new Lataxis object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.layout.geo.Lataxis`
dtick
Sets the graticule's longitude/latitude tic... |
Construct a new Lataxis object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.layout.geo.Lataxis`
dtick
Sets the graticule's longitude/latitude tic... | def __init__(
self,
arg=None,
dtick=None,
gridcolor=None,
gridwidth=None,
range=None,
showgrid=None,
tick0=None,
**kwargs
):
"""
Construct a new Lataxis object
Parameters
----------
arg
... | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"dtick",
"=",
"None",
",",
"gridcolor",
"=",
"None",
",",
"gridwidth",
"=",
"None",
",",
"range",
"=",
"None",
",",
"showgrid",
"=",
"None",
",",
"tick0",
"=",
"None",
",",
"*",
"*",
"... | [
197,
4
] | [
295,
34
] | python | en | ['en', 'error', 'th'] | False |
Labelfont.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 |
Labelfont.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 |
Labelfont.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 |
Labelfont.__init__ | (self, arg=None, color=None, family=None, size=None, **kwargs) |
Construct a new Labelfont object
Sets the font used for labeling the contour levels. The default
color comes from the lines, if shown. The default family and
size come from `layout.font`.
Parameters
----------
arg
dict of properties compatib... |
Construct a new Labelfont object
Sets the font used for labeling the contour levels. The default
color comes from the lines, if shown. The default family and
size come from `layout.font`. | def __init__(self, arg=None, color=None, family=None, size=None, **kwargs):
"""
Construct a new Labelfont object
Sets the font used for labeling the contour levels. The default
color comes from the lines, if shown. The default family and
size come from `layout.font`.
... | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"color",
"=",
"None",
",",
"family",
"=",
"None",
",",
"size",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Labelfont",
",",
"self",
")",
".",
"__init__",
"(",
"\"lab... | [
143,
4
] | [
228,
34
] | python | en | ['en', 'error', 'th'] | False |
make_params | (**kwargs) |
Helper to create a params dict, skipping undefined entries.
:returns: (dict) A params dict to pass to `request`.
|
Helper to create a params dict, skipping undefined entries. | def make_params(**kwargs):
"""
Helper to create a params dict, skipping undefined entries.
:returns: (dict) A params dict to pass to `request`.
"""
return {k: v for k, v in kwargs.items() if v is not None} | [
"def",
"make_params",
"(",
"*",
"*",
"kwargs",
")",
":",
"return",
"{",
"k",
":",
"v",
"for",
"k",
",",
"v",
"in",
"kwargs",
".",
"items",
"(",
")",
"if",
"v",
"is",
"not",
"None",
"}"
] | [
13,
0
] | [
20,
61
] | python | en | ['en', 'error', 'th'] | False |
build_url | (resource, id="", route="") |
Create a url for a request on a V2 resource.
:param (str) resource: E.g., 'files', 'plots', 'grids', etc.
:param (str) id: The unique identifier for the resource.
:param (str) route: Detail/list route. E.g., 'restore', 'lookup', etc.
:return: (str) The url.
|
Create a url for a request on a V2 resource. | def build_url(resource, id="", route=""):
"""
Create a url for a request on a V2 resource.
:param (str) resource: E.g., 'files', 'plots', 'grids', etc.
:param (str) id: The unique identifier for the resource.
:param (str) route: Detail/list route. E.g., 'restore', 'lookup', etc.
:return: (str) ... | [
"def",
"build_url",
"(",
"resource",
",",
"id",
"=",
"\"\"",
",",
"route",
"=",
"\"\"",
")",
":",
"base",
"=",
"config",
".",
"get_config",
"(",
")",
"[",
"\"plotly_api_domain\"",
"]",
"formatter",
"=",
"{",
"\"base\"",
":",
"base",
",",
"\"resource\"",
... | [
23,
0
] | [
50,
14
] | python | en | ['en', 'error', 'th'] | False |
validate_response | (response) |
Raise a helpful PlotlyRequestError for failed requests.
:param (requests.Response) response: A Response object from an api request.
:raises: (PlotlyRequestError) If the request failed for any reason.
:returns: (None)
|
Raise a helpful PlotlyRequestError for failed requests. | def validate_response(response):
"""
Raise a helpful PlotlyRequestError for failed requests.
:param (requests.Response) response: A Response object from an api request.
:raises: (PlotlyRequestError) If the request failed for any reason.
:returns: (None)
"""
if response.ok:
return
... | [
"def",
"validate_response",
"(",
"response",
")",
":",
"if",
"response",
".",
"ok",
":",
"return",
"content",
"=",
"response",
".",
"content",
"status_code",
"=",
"response",
".",
"status_code",
"try",
":",
"parsed_content",
"=",
"response",
".",
"json",
"("... | [
53,
0
] | [
81,
70
] | python | en | ['en', 'error', 'th'] | False |
get_headers | () |
Using session credentials/config, get headers for a V2 API request.
Users may have their own proxy layer and so we free up the `authorization`
header for this purpose (instead adding the user authorization in a new
`plotly-authorization` header). See pull #239.
:returns: (dict) Headers to add to ... |
Using session credentials/config, get headers for a V2 API request. | def get_headers():
"""
Using session credentials/config, get headers for a V2 API request.
Users may have their own proxy layer and so we free up the `authorization`
header for this purpose (instead adding the user authorization in a new
`plotly-authorization` header). See pull #239.
:returns:... | [
"def",
"get_headers",
"(",
")",
":",
"from",
"plotly",
"import",
"version",
"creds",
"=",
"config",
".",
"get_credentials",
"(",
")",
"headers",
"=",
"{",
"\"plotly-client-platform\"",
":",
"\"python {}\"",
".",
"format",
"(",
"version",
".",
"stable_semver",
... | [
84,
0
] | [
115,
18
] | python | en | ['en', 'error', 'th'] | False |
request | (method, url, **kwargs) |
Central place to make any api v2 api request.
:param (str) method: The request method ('get', 'put', 'delete', ...).
:param (str) url: The full api url to make the request to.
:param kwargs: These are passed along (but possibly mutated) to requests.
:return: (requests.Response) The response direct... |
Central place to make any api v2 api request. | def request(method, url, **kwargs):
"""
Central place to make any api v2 api request.
:param (str) method: The request method ('get', 'put', 'delete', ...).
:param (str) url: The full api url to make the request to.
:param kwargs: These are passed along (but possibly mutated) to requests.
:retu... | [
"def",
"request",
"(",
"method",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"\"headers\"",
"]",
"=",
"dict",
"(",
"kwargs",
".",
"get",
"(",
"\"headers\"",
",",
"{",
"}",
")",
",",
"*",
"*",
"get_headers",
"(",
")",
")",
"# Cha... | [
137,
0
] | [
180,
19
] | python | en | ['en', 'error', 'th'] | False |
Uniformtext.minsize | (self) |
Sets the minimum text size between traces of the same type.
The 'minsize' property is a number and may be specified as:
- An int or float in the interval [0, inf]
Returns
-------
int|float
|
Sets the minimum text size between traces of the same type.
The 'minsize' property is a number and may be specified as:
- An int or float in the interval [0, inf] | def minsize(self):
"""
Sets the minimum text size between traces of the same type.
The 'minsize' property is a number and may be specified as:
- An int or float in the interval [0, inf]
Returns
-------
int|float
"""
return self["minsize"] | [
"def",
"minsize",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"minsize\"",
"]"
] | [
15,
4
] | [
26,
30
] | python | en | ['en', 'error', 'th'] | False |
Uniformtext.mode | (self) |
Determines how the font size for various text elements are
uniformed between each trace type. If the computed text sizes
were smaller than the minimum size defined by
`uniformtext.minsize` using "hide" option hides the text; and
using "show" option shows the text without further... |
Determines how the font size for various text elements are
uniformed between each trace type. If the computed text sizes
were smaller than the minimum size defined by
`uniformtext.minsize` using "hide" option hides the text; and
using "show" option shows the text without further... | def mode(self):
"""
Determines how the font size for various text elements are
uniformed between each trace type. If the computed text sizes
were smaller than the minimum size defined by
`uniformtext.minsize` using "hide" option hides the text; and
using "show" option sho... | [
"def",
"mode",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"mode\"",
"]"
] | [
35,
4
] | [
54,
27
] | python | en | ['en', 'error', 'th'] | False |
Uniformtext.__init__ | (self, arg=None, minsize=None, mode=None, **kwargs) |
Construct a new Uniformtext object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.layout.Uniformtext`
minsize
Sets the minimum text size between tr... |
Construct a new Uniformtext object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.layout.Uniformtext`
minsize
Sets the minimum text size between tr... | def __init__(self, arg=None, minsize=None, mode=None, **kwargs):
"""
Construct a new Uniformtext object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.layout.Un... | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"minsize",
"=",
"None",
",",
"mode",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Uniformtext",
",",
"self",
")",
".",
"__init__",
"(",
"\"uniformtext\"",
")",
"if",
"\... | [
79,
4
] | [
150,
34
] | python | en | ['en', 'error', 'th'] | False |
get_sampler_type | (sampler_type) | Get the type and mode of points sampler.
Args:
sampler_type (str): The type of points sampler.
The valid value are "D-FPS", "F-FPS", or "FS".
Returns:
class: Points sampler type.
| Get the type and mode of points sampler. | def get_sampler_type(sampler_type):
"""Get the type and mode of points sampler.
Args:
sampler_type (str): The type of points sampler.
The valid value are "D-FPS", "F-FPS", or "FS".
Returns:
class: Points sampler type.
"""
if sampler_type == 'D-FPS':
sampler = DF... | [
"def",
"get_sampler_type",
"(",
"sampler_type",
")",
":",
"if",
"sampler_type",
"==",
"'D-FPS'",
":",
"sampler",
"=",
"DFPS_Sampler",
"elif",
"sampler_type",
"==",
"'F-FPS'",
":",
"sampler",
"=",
"FFPS_Sampler",
"elif",
"sampler_type",
"==",
"'FS'",
":",
"sample... | [
10,
0
] | [
30,
18
] | python | en | ['en', 'en', 'en'] | True |
Points_Sampler.forward | (self, points_xyz, features) | forward.
Args:
points_xyz (Tensor): (B, N, 3) xyz coordinates of the features.
features (Tensor): (B, C, N) Descriptors of the features.
Return:
Tensor: (B, npoint, sample_num) Indices of sampled points.
| forward. | def forward(self, points_xyz, features):
"""forward.
Args:
points_xyz (Tensor): (B, N, 3) xyz coordinates of the features.
features (Tensor): (B, C, N) Descriptors of the features.
Return:
Tensor: (B, npoint, sample_num) Indices of sampled points.
""... | [
"def",
"forward",
"(",
"self",
",",
"points_xyz",
",",
"features",
")",
":",
"indices",
"=",
"[",
"]",
"last_fps_end_index",
"=",
"0",
"for",
"fps_sample_range",
",",
"sampler",
",",
"npoint",
"in",
"zip",
"(",
"self",
".",
"fps_sample_range_list",
",",
"s... | [
65,
4
] | [
98,
22
] | python | en | ['en', 'cy', 'en'] | False |
DFPS_Sampler.forward | (self, points, features, npoint) | Sampling points with D-FPS. | Sampling points with D-FPS. | def forward(self, points, features, npoint):
"""Sampling points with D-FPS."""
fps_idx = furthest_point_sample(points.contiguous(), npoint)
return fps_idx | [
"def",
"forward",
"(",
"self",
",",
"points",
",",
"features",
",",
"npoint",
")",
":",
"fps_idx",
"=",
"furthest_point_sample",
"(",
"points",
".",
"contiguous",
"(",
")",
",",
"npoint",
")",
"return",
"fps_idx"
] | [
110,
4
] | [
113,
22
] | python | en | ['en', 'en', 'en'] | True |
FFPS_Sampler.forward | (self, points, features, npoint) | Sampling points with F-FPS. | Sampling points with F-FPS. | def forward(self, points, features, npoint):
"""Sampling points with F-FPS."""
features_for_fps = torch.cat([points, features.transpose(1, 2)], dim=2)
features_dist = calc_square_dist(
features_for_fps, features_for_fps, norm=False)
fps_idx = furthest_point_sample_with_dist(f... | [
"def",
"forward",
"(",
"self",
",",
"points",
",",
"features",
",",
"npoint",
")",
":",
"features_for_fps",
"=",
"torch",
".",
"cat",
"(",
"[",
"points",
",",
"features",
".",
"transpose",
"(",
"1",
",",
"2",
")",
"]",
",",
"dim",
"=",
"2",
")",
... | [
125,
4
] | [
131,
22
] | python | en | ['en', 'en', 'en'] | True |
FS_Sampler.forward | (self, points, features, npoint) | Sampling points with FS_Sampling. | Sampling points with FS_Sampling. | def forward(self, points, features, npoint):
"""Sampling points with FS_Sampling."""
features_for_fps = torch.cat([points, features.transpose(1, 2)], dim=2)
features_dist = calc_square_dist(
features_for_fps, features_for_fps, norm=False)
fps_idx_ffps = furthest_point_sample_... | [
"def",
"forward",
"(",
"self",
",",
"points",
",",
"features",
",",
"npoint",
")",
":",
"features_for_fps",
"=",
"torch",
".",
"cat",
"(",
"[",
"points",
",",
"features",
".",
"transpose",
"(",
"1",
",",
"2",
")",
"]",
",",
"dim",
"=",
"2",
")",
... | [
143,
4
] | [
151,
22
] | python | en | ['en', 'da', 'en'] | True |
calc_square_dist | (point_feat_a, point_feat_b, norm=True) | Calculating square distance between a and b.
Args:
point_feat_a (Tensor): (B, N, C) Feature vector of each point.
point_feat_b (Tensor): (B, M, C) Feature vector of each point.
norm (Bool): Whether to normalize the distance.
Default: True.
Returns:
Tensor: (B, N, M)... | Calculating square distance between a and b. | def calc_square_dist(point_feat_a, point_feat_b, norm=True):
"""Calculating square distance between a and b.
Args:
point_feat_a (Tensor): (B, N, C) Feature vector of each point.
point_feat_b (Tensor): (B, M, C) Feature vector of each point.
norm (Bool): Whether to normalize the distance... | [
"def",
"calc_square_dist",
"(",
"point_feat_a",
",",
"point_feat_b",
",",
"norm",
"=",
"True",
")",
":",
"length_a",
"=",
"point_feat_a",
".",
"shape",
"[",
"1",
"]",
"length_b",
"=",
"point_feat_b",
".",
"shape",
"[",
"1",
"]",
"num_channel",
"=",
"point_... | [
3,
0
] | [
30,
15
] | python | en | ['en', 'en', 'en'] | True |
AbstractCrowdsourcingTest._setup | (self) |
To be run before a test.
Should be called in a pytest setup/teardown fixture.
|
To be run before a test. | def _setup(self):
"""
To be run before a test.
Should be called in a pytest setup/teardown fixture.
"""
random.seed(0)
np.random.seed(0)
torch.manual_seed(0)
self.operator = None | [
"def",
"_setup",
"(",
"self",
")",
":",
"random",
".",
"seed",
"(",
"0",
")",
"np",
".",
"random",
".",
"seed",
"(",
"0",
")",
"torch",
".",
"manual_seed",
"(",
"0",
")",
"self",
".",
"operator",
"=",
"None"
] | [
34,
4
] | [
45,
28
] | python | en | ['en', 'error', 'th'] | False |
AbstractCrowdsourcingTest._teardown | (self) |
To be run after a test.
Should be called in a pytest setup/teardown fixture.
|
To be run after a test. | def _teardown(self):
"""
To be run after a test.
Should be called in a pytest setup/teardown fixture.
"""
if self.operator is not None:
self.operator.force_shutdown() | [
"def",
"_teardown",
"(",
"self",
")",
":",
"if",
"self",
".",
"operator",
"is",
"not",
"None",
":",
"self",
".",
"operator",
".",
"force_shutdown",
"(",
")"
] | [
47,
4
] | [
55,
42
] | python | en | ['en', 'error', 'th'] | False |
AbstractCrowdsourcingTest._set_up_config | (
self,
blueprint_type: str,
task_directory: str,
overrides: Optional[List[str]] = None,
) |
Set up the config and database.
Uses the Hydra compose() API for unit testing and a temporary directory to store
the test database.
:param blueprint_type: string uniquely specifying Blueprint class
:param task_directory: directory containing the `conf/` configuration folder.
... |
Set up the config and database. | def _set_up_config(
self,
blueprint_type: str,
task_directory: str,
overrides: Optional[List[str]] = None,
):
"""
Set up the config and database.
Uses the Hydra compose() API for unit testing and a temporary directory to store
the test database.
... | [
"def",
"_set_up_config",
"(",
"self",
",",
"blueprint_type",
":",
"str",
",",
"task_directory",
":",
"str",
",",
"overrides",
":",
"Optional",
"[",
"List",
"[",
"str",
"]",
"]",
"=",
"None",
",",
")",
":",
"# Define the configuration settings",
"relative_task_... | [
57,
4
] | [
105,
63
] | python | en | ['en', 'error', 'th'] | False |
AbstractCrowdsourcingTest._set_up_server | (self, shared_state: Optional[SharedTaskState] = None) |
Set up the operator and server.
|
Set up the operator and server.
| def _set_up_server(self, shared_state: Optional[SharedTaskState] = None):
"""
Set up the operator and server.
"""
self.operator = Operator(self.db)
self.operator.validate_and_run_config(
self.config.mephisto, shared_state=shared_state
)
self.server = s... | [
"def",
"_set_up_server",
"(",
"self",
",",
"shared_state",
":",
"Optional",
"[",
"SharedTaskState",
"]",
"=",
"None",
")",
":",
"self",
".",
"operator",
"=",
"Operator",
"(",
"self",
".",
"db",
")",
"self",
".",
"operator",
".",
"validate_and_run_config",
... | [
107,
4
] | [
115,
67
] | python | en | ['en', 'error', 'th'] | False |
AbstractCrowdsourcingTest._get_channel_info | (self) |
Return channel info for the currently running job.
|
Return channel info for the currently running job.
| def _get_channel_info(self):
"""
Return channel info for the currently running job.
"""
channels = list(self.operator.supervisor.channels.values())
if len(channels) > 0:
return channels[0]
else:
raise ValueError('No channel could be detected!') | [
"def",
"_get_channel_info",
"(",
"self",
")",
":",
"channels",
"=",
"list",
"(",
"self",
".",
"operator",
".",
"supervisor",
".",
"channels",
".",
"values",
"(",
")",
")",
"if",
"len",
"(",
"channels",
")",
">",
"0",
":",
"return",
"channels",
"[",
"... | [
117,
4
] | [
125,
61
] | python | en | ['en', 'error', 'th'] | False |
AbstractCrowdsourcingTest._register_mock_agents | (self, num_agents: int = 1) |
Register mock agents for testing, taking the place of crowdsourcing workers.
Specify the number of agents to register. Return the agents' IDs after creation.
|
Register mock agents for testing, taking the place of crowdsourcing workers. | def _register_mock_agents(self, num_agents: int = 1) -> List[str]:
"""
Register mock agents for testing, taking the place of crowdsourcing workers.
Specify the number of agents to register. Return the agents' IDs after creation.
"""
for idx in range(num_agents):
mo... | [
"def",
"_register_mock_agents",
"(",
"self",
",",
"num_agents",
":",
"int",
"=",
"1",
")",
"->",
"List",
"[",
"str",
"]",
":",
"for",
"idx",
"in",
"range",
"(",
"num_agents",
")",
":",
"mock_worker_name",
"=",
"f\"MOCK_WORKER_{idx:d}\"",
"max_num_tries",
"="... | [
127,
4
] | [
177,
24
] | python | en | ['en', 'error', 'th'] | False |
AbstractOneTurnCrowdsourcingTest._test_agent_state | (
self, task_data: Dict[str, Any], data_regression: DataRegressionFixture
) |
Test that the actual agent state matches the expected state.
Get the final agent state given the input task data and check that it is as
expected.
|
Test that the actual agent state matches the expected state. | def _test_agent_state(
self, task_data: Dict[str, Any], data_regression: DataRegressionFixture
):
"""
Test that the actual agent state matches the expected state.
Get the final agent state given the input task data and check that it is as
expected.
"""
state ... | [
"def",
"_test_agent_state",
"(",
"self",
",",
"task_data",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"data_regression",
":",
"DataRegressionFixture",
")",
":",
"state",
"=",
"self",
".",
"_get_agent_state",
"(",
"task_data",
"=",
"task_data",
")",
"self... | [
188,
4
] | [
198,
77
] | python | en | ['en', 'error', 'th'] | False |
AbstractOneTurnCrowdsourcingTest._get_agent_state | (self, task_data: Dict[str, Any]) |
Submit user task data and return the final agent state.
Register a mock human agent, request initial data to define the 'inputs' field
of the agent state, make the agent act to define the 'outputs' field of the
agent state, and return the agent state.
|
Submit user task data and return the final agent state. | def _get_agent_state(self, task_data: Dict[str, Any]):
"""
Submit user task data and return the final agent state.
Register a mock human agent, request initial data to define the 'inputs' field
of the agent state, make the agent act to define the 'outputs' field of the
agent sta... | [
"def",
"_get_agent_state",
"(",
"self",
",",
"task_data",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
":",
"# Set up the mock human agent",
"agent_id",
"=",
"self",
".",
"_register_mock_agents",
"(",
"num_agents",
"=",
"1",
")",
"[",
"0",
"]",
"# Set init... | [
200,
4
] | [
220,
56
] | python | en | ['en', 'error', 'th'] | False |
AbstractOneTurnCrowdsourcingTest._check_agent_state | (
self, state: Dict[str, Any], data_regression: DataRegressionFixture
) |
Given an agent state, test that it is as expected.
|
Given an agent state, test that it is as expected.
| def _check_agent_state(
self, state: Dict[str, Any], data_regression: DataRegressionFixture
):
"""
Given an agent state, test that it is as expected.
"""
del state['times'] # Delete variable timestamps
data_regression.check(state) | [
"def",
"_check_agent_state",
"(",
"self",
",",
"state",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"data_regression",
":",
"DataRegressionFixture",
")",
":",
"del",
"state",
"[",
"'times'",
"]",
"# Delete variable timestamps",
"data_regression",
".",
"check"... | [
222,
4
] | [
229,
36
] | python | en | ['en', 'error', 'th'] | False |
AbstractParlAIChatTest._test_agent_states | (
self,
num_agents: int,
agent_display_ids: Sequence[str],
agent_messages: List[Sequence[str]],
form_messages: Sequence[str],
form_task_data: Sequence[Dict[str, Any]],
expected_states: Sequence[Dict[str, Any]],
agent_task_data: Optional[List[Sequence[Dict[... |
Test that the actual agent states match the expected states.
Register mock human agents, request initial data to define the 'inputs' fields
of the agent states, make the agents have a conversation to define the 'outputs'
fields of the agent states, and then check that the agent states ... |
Test that the actual agent states match the expected states. | def _test_agent_states(
self,
num_agents: int,
agent_display_ids: Sequence[str],
agent_messages: List[Sequence[str]],
form_messages: Sequence[str],
form_task_data: Sequence[Dict[str, Any]],
expected_states: Sequence[Dict[str, Any]],
agent_task_data: Option... | [
"def",
"_test_agent_states",
"(",
"self",
",",
"num_agents",
":",
"int",
",",
"agent_display_ids",
":",
"Sequence",
"[",
"str",
"]",
",",
"agent_messages",
":",
"List",
"[",
"Sequence",
"[",
"str",
"]",
"]",
",",
"form_messages",
":",
"Sequence",
"[",
"str... | [
237,
4
] | [
359,
21
] | python | en | ['en', 'error', 'th'] | False |
AbstractParlAIChatTest._check_output_key | (
self: Union['AbstractParlAIChatTest', unittest.TestCase],
key: str,
actual_value: Any,
expected_value: Any,
) |
Check the actual and expected values, given that they come from the specified
key of the output message dictionary.
This function can be extended to handle special cases for subclassed Mephisto
tasks.
|
Check the actual and expected values, given that they come from the specified
key of the output message dictionary. | def _check_output_key(
self: Union['AbstractParlAIChatTest', unittest.TestCase],
key: str,
actual_value: Any,
expected_value: Any,
):
# TODO: remove typing of self after switching to pytest regressions, in which we
# no longer inherit from TestCase
"""
... | [
"def",
"_check_output_key",
"(",
"self",
":",
"Union",
"[",
"'AbstractParlAIChatTest'",
",",
"unittest",
".",
"TestCase",
"]",
",",
"key",
":",
"str",
",",
"actual_value",
":",
"Any",
",",
"expected_value",
":",
"Any",
",",
")",
":",
"# TODO: remove typing of ... | [
361,
4
] | [
394,
17
] | python | en | ['en', 'error', 'th'] | False |
AbstractParlAIChatTest._send_agent_message | (
self, agent_id: str, agent_display_id: str, text: str, task_data: Dict[str, Any]
) |
Have the agent specified by agent_id send the specified text and task data with
the given display ID string.
|
Have the agent specified by agent_id send the specified text and task data with
the given display ID string.
| def _send_agent_message(
self, agent_id: str, agent_display_id: str, text: str, task_data: Dict[str, Any]
):
"""
Have the agent specified by agent_id send the specified text and task data with
the given display ID string.
"""
act_content = {
"text": text,
... | [
"def",
"_send_agent_message",
"(",
"self",
",",
"agent_id",
":",
"str",
",",
"agent_display_id",
":",
"str",
",",
"text",
":",
"str",
",",
"task_data",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
":",
"act_content",
"=",
"{",
"\"text\"",
":",
"text"... | [
396,
4
] | [
409,
78
] | python | en | ['en', 'error', 'th'] | False |
CredentialStoredHandler.handle | (self, context: RequestContext, responder: BaseResponder) |
Message handler logic for credential stored messages.
Args:
context: request context
responder: responder callback
|
Message handler logic for credential stored messages. | async def handle(self, context: RequestContext, responder: BaseResponder):
"""
Message handler logic for credential stored messages.
Args:
context: request context
responder: responder callback
"""
self._logger.debug(f"CredentialStoredHandler called with ... | [
"async",
"def",
"handle",
"(",
"self",
",",
"context",
":",
"RequestContext",
",",
"responder",
":",
"BaseResponder",
")",
":",
"self",
".",
"_logger",
".",
"debug",
"(",
"f\"CredentialStoredHandler called with context {context}\"",
")",
"assert",
"isinstance",
"(",... | [
16,
4
] | [
33,
67
] | python | en | ['en', 'error', 'th'] | False |
ConnectionTarget.__init__ | (
self,
*,
did: str = None,
endpoint: str = None,
label: str = None,
recipient_keys: Sequence[str] = None,
routing_keys: Sequence[str] = None,
sender_key: str = None,
) |
Initialize a ConnectionTarget instance.
Args:
did: A did for the connection
endpoint: An endpoint for the connection
label: A label for the connection
recipient_key: A list of recipient keys
routing_keys: A list of routing keys
|
Initialize a ConnectionTarget instance. | def __init__(
self,
*,
did: str = None,
endpoint: str = None,
label: str = None,
recipient_keys: Sequence[str] = None,
routing_keys: Sequence[str] = None,
sender_key: str = None,
):
"""
Initialize a ConnectionTarget instance.
A... | [
"def",
"__init__",
"(",
"self",
",",
"*",
",",
"did",
":",
"str",
"=",
"None",
",",
"endpoint",
":",
"str",
"=",
"None",
",",
"label",
":",
"str",
"=",
"None",
",",
"recipient_keys",
":",
"Sequence",
"[",
"str",
"]",
"=",
"None",
",",
"routing_keys... | [
18,
4
] | [
43,
36
] | python | en | ['en', 'error', 'th'] | False |
main | (config) |
Creates .unfiltered files from .sliced files.
input: a .sliced file of logs (in ParlaiDialog format) from Mturk task 1, each of
which starts with an initial prompt or topic request, and ends with a y_exp
output: a .unfiltered file (in self-feeding format) with every utterance output by
bot... |
Creates .unfiltered files from .sliced files. | def main(config):
"""
Creates .unfiltered files from .sliced files.
input: a .sliced file of logs (in ParlaiDialog format) from Mturk task 1, each of
which starts with an initial prompt or topic request, and ends with a y_exp
output: a .unfiltered file (in self-feeding format) with every uttera... | [
"def",
"main",
"(",
"config",
")",
":",
"examples",
"=",
"[",
"]",
"episodes",
"=",
"[",
"e",
"for",
"e",
"in",
"extract_parlai_episodes",
"(",
"config",
"[",
"'infile'",
"]",
")",
"]",
"for",
"episode",
"in",
"episodes",
":",
"history",
"=",
"[",
"]... | [
25,
0
] | [
64,
5
] | python | en | ['en', 'error', 'th'] | False |
Tickformatstop.dtickrange | (self) |
range [*min*, *max*], where "min", "max" - dtick values which
describe some zoom level, it is possible to omit "min" or "max"
value by passing "null"
The 'dtickrange' property is an info array that may be specified as:
* a list or tuple of 2 elements where:
(0) The... |
range [*min*, *max*], where "min", "max" - dtick values which
describe some zoom level, it is possible to omit "min" or "max"
value by passing "null"
The 'dtickrange' property is an info array that may be specified as:
* a list or tuple of 2 elements where:
(0) The... | def dtickrange(self):
"""
range [*min*, *max*], where "min", "max" - dtick values which
describe some zoom level, it is possible to omit "min" or "max"
value by passing "null"
The 'dtickrange' property is an info array that may be specified as:
* a list or tuple... | [
"def",
"dtickrange",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"dtickrange\"",
"]"
] | [
15,
4
] | [
31,
33
] | python | en | ['en', 'error', 'th'] | False |
Tickformatstop.enabled | (self) |
Determines whether or not this stop is used. If `false`, this
stop is ignored even within its `dtickrange`.
The 'enabled' property must be specified as a bool
(either True, or False)
Returns
-------
bool
|
Determines whether or not this stop is used. If `false`, this
stop is ignored even within its `dtickrange`.
The 'enabled' property must be specified as a bool
(either True, or False) | def enabled(self):
"""
Determines whether or not this stop is used. If `false`, this
stop is ignored even within its `dtickrange`.
The 'enabled' property must be specified as a bool
(either True, or False)
Returns
-------
bool
"""
ret... | [
"def",
"enabled",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"enabled\"",
"]"
] | [
40,
4
] | [
52,
30
] | python | en | ['en', 'error', 'th'] | False |
Tickformatstop.name | (self) |
When used in a template, named items are created in the output
figure in addition to any items the figure already has in this
array. You can modify these items in the output figure by
making your own item with `templateitemname` matching this
`name` alongside your modifications ... |
When used in a template, named items are created in the output
figure in addition to any items the figure already has in this
array. You can modify these items in the output figure by
making your own item with `templateitemname` matching this
`name` alongside your modifications ... | def name(self):
"""
When used in a template, named items are created in the output
figure in addition to any items the figure already has in this
array. You can modify these items in the output figure by
making your own item with `templateitemname` matching this
`name` al... | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"name\"",
"]"
] | [
61,
4
] | [
79,
27
] | python | en | ['en', 'error', 'th'] | False |
Tickformatstop.templateitemname | (self) |
Used to refer to a named item in this array in the template.
Named items from the template will be created even without a
matching item in the input figure, but you can modify one by
making an item with `templateitemname` matching its `name`,
alongside your modifications (includ... |
Used to refer to a named item in this array in the template.
Named items from the template will be created even without a
matching item in the input figure, but you can modify one by
making an item with `templateitemname` matching its `name`,
alongside your modifications (includ... | def templateitemname(self):
"""
Used to refer to a named item in this array in the template.
Named items from the template will be created even without a
matching item in the input figure, but you can modify one by
making an item with `templateitemname` matching its `name`,
... | [
"def",
"templateitemname",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"templateitemname\"",
"]"
] | [
88,
4
] | [
107,
39
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.