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
sequence
start_point
sequence
end_point
sequence
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
SelfFeedingAgent.train_step
(self, batch)
Train on a single batch of examples.
Train on a single batch of examples.
def train_step(self, batch): """ Train on a single batch of examples. """ if batch.text_vec is None: return self.model.train() self.optimizer.zero_grad() batchsize = batch.text_vec.size(0) self.metrics['examples'] += batchsize if self.subtask == 'dialog': loss, preds, _ = self.dialog_step(batch) elif self.subtask == 'feedback': loss, preds, _ = self.feedback_step(batch) elif self.subtask == 'satisfaction': loss, preds = self.satisfaction_step(batch) preds = [str(p) for p in preds] # Weight loss by task-weight loss *= self.task_weight[self.subtask] loss.backward() self.update_params() return Output(preds)
[ "def", "train_step", "(", "self", ",", "batch", ")", ":", "if", "batch", ".", "text_vec", "is", "None", ":", "return", "self", ".", "model", ".", "train", "(", ")", "self", ".", "optimizer", ".", "zero_grad", "(", ")", "batchsize", "=", "batch", ".", "text_vec", ".", "size", "(", "0", ")", "self", ".", "metrics", "[", "'examples'", "]", "+=", "batchsize", "if", "self", ".", "subtask", "==", "'dialog'", ":", "loss", ",", "preds", ",", "_", "=", "self", ".", "dialog_step", "(", "batch", ")", "elif", "self", ".", "subtask", "==", "'feedback'", ":", "loss", ",", "preds", ",", "_", "=", "self", ".", "feedback_step", "(", "batch", ")", "elif", "self", ".", "subtask", "==", "'satisfaction'", ":", "loss", ",", "preds", "=", "self", ".", "satisfaction_step", "(", "batch", ")", "preds", "=", "[", "str", "(", "p", ")", "for", "p", "in", "preds", "]", "# Weight loss by task-weight", "loss", "*=", "self", ".", "task_weight", "[", "self", ".", "subtask", "]", "loss", ".", "backward", "(", ")", "self", ".", "update_params", "(", ")", "return", "Output", "(", "preds", ")" ]
[ 414, 4 ]
[ 441, 28 ]
python
en
['en', 'error', 'th']
False
SelfFeedingAgent.reset_metrics
(self)
Reset metrics.
Reset metrics.
def reset_metrics(self): """ Reset metrics. """ super().reset_metrics() self.metrics['examples'] = 0 if 'dialog' in self.subtasks: self.metrics['dia_exs'] = 0 self.metrics['dia_loss'] = 0.0 self.metrics['dia_rank'] = 0 self.metrics['dia_correct'] = 0 if 'feedback' in self.subtasks: self.metrics['fee_exs'] = 0 self.metrics['fee_loss'] = 0.0 self.metrics['fee_rank'] = 0 self.metrics['fee_correct'] = 0.0 if 'satisfaction' in self.subtasks: self.metrics['sat_exs'] = 0 self.metrics['sat_loss'] = 0 self.metrics['sat_tp'] = 0 self.metrics['sat_fp'] = 0 self.metrics['sat_tn'] = 0 self.metrics['sat_fn'] = 0
[ "def", "reset_metrics", "(", "self", ")", ":", "super", "(", ")", ".", "reset_metrics", "(", ")", "self", ".", "metrics", "[", "'examples'", "]", "=", "0", "if", "'dialog'", "in", "self", ".", "subtasks", ":", "self", ".", "metrics", "[", "'dia_exs'", "]", "=", "0", "self", ".", "metrics", "[", "'dia_loss'", "]", "=", "0.0", "self", ".", "metrics", "[", "'dia_rank'", "]", "=", "0", "self", ".", "metrics", "[", "'dia_correct'", "]", "=", "0", "if", "'feedback'", "in", "self", ".", "subtasks", ":", "self", ".", "metrics", "[", "'fee_exs'", "]", "=", "0", "self", ".", "metrics", "[", "'fee_loss'", "]", "=", "0.0", "self", ".", "metrics", "[", "'fee_rank'", "]", "=", "0", "self", ".", "metrics", "[", "'fee_correct'", "]", "=", "0.0", "if", "'satisfaction'", "in", "self", ".", "subtasks", ":", "self", ".", "metrics", "[", "'sat_exs'", "]", "=", "0", "self", ".", "metrics", "[", "'sat_loss'", "]", "=", "0", "self", ".", "metrics", "[", "'sat_tp'", "]", "=", "0", "self", ".", "metrics", "[", "'sat_fp'", "]", "=", "0", "self", ".", "metrics", "[", "'sat_tn'", "]", "=", "0", "self", ".", "metrics", "[", "'sat_fn'", "]", "=", "0" ]
[ 616, 4 ]
[ 638, 38 ]
python
en
['en', 'error', 'th']
False
SelfFeedingAgent.report
(self)
Report metrics from model's perspective.
Report metrics from model's perspective.
def report(self): """ Report metrics from model's perspective. """ m = TorchAgent.report(self) # Skip TorchRankerAgent; totally redundant examples = self.metrics['examples'] if examples > 0: m['examples'] = examples if 'dialog' in self.subtasks and self.metrics['dia_exs'] > 0: m['dia_loss'] = self.metrics['dia_loss'] / self.metrics['dia_exs'] m['dia_rank'] = self.metrics['dia_rank'] / self.metrics['dia_exs'] m['dia_acc'] = self.metrics['dia_correct'] / self.metrics['dia_exs'] m['dia_exs'] = self.metrics['dia_exs'] if 'feedback' in self.subtasks and self.metrics['fee_exs'] > 0: m['fee_loss'] = self.metrics['fee_loss'] / self.metrics['fee_exs'] m['fee_rank'] = self.metrics['fee_rank'] / self.metrics['fee_exs'] m['fee_acc'] = self.metrics['fee_correct'] / self.metrics['fee_exs'] m['fee_exs'] = self.metrics['fee_exs'] m['fee_exs'] = self.metrics['fee_exs'] if 'satisfaction' in self.subtasks and self.metrics['sat_exs'] > 0: tp = self.metrics['sat_tp'] tn = self.metrics['sat_tn'] fp = self.metrics['sat_fp'] fn = self.metrics['sat_fn'] assert tp + tn + fp + fn == self.metrics['sat_exs'] m['sat_loss'] = self.metrics['sat_loss'] / self.metrics['sat_exs'] m['sat_pr'] = tp / (tp + fp + EPS) m['sat_re'] = tp / (tp + fn + EPS) pr = m['sat_pr'] re = m['sat_re'] m['sat_f1'] = (2 * pr * re) / (pr + re) if (pr and re) else 0.0 m['sat_acc'] = (tp + tn) / self.metrics['sat_exs'] m['sat_exs'] = self.metrics['sat_exs'] for k, v in m.items(): # clean up: rounds to sigfigs and converts tensors to floats if isinstance(v, float): m[k] = round_sigfigs(v, 4) else: m[k] = v return m
[ "def", "report", "(", "self", ")", ":", "m", "=", "TorchAgent", ".", "report", "(", "self", ")", "# Skip TorchRankerAgent; totally redundant", "examples", "=", "self", ".", "metrics", "[", "'examples'", "]", "if", "examples", ">", "0", ":", "m", "[", "'examples'", "]", "=", "examples", "if", "'dialog'", "in", "self", ".", "subtasks", "and", "self", ".", "metrics", "[", "'dia_exs'", "]", ">", "0", ":", "m", "[", "'dia_loss'", "]", "=", "self", ".", "metrics", "[", "'dia_loss'", "]", "/", "self", ".", "metrics", "[", "'dia_exs'", "]", "m", "[", "'dia_rank'", "]", "=", "self", ".", "metrics", "[", "'dia_rank'", "]", "/", "self", ".", "metrics", "[", "'dia_exs'", "]", "m", "[", "'dia_acc'", "]", "=", "self", ".", "metrics", "[", "'dia_correct'", "]", "/", "self", ".", "metrics", "[", "'dia_exs'", "]", "m", "[", "'dia_exs'", "]", "=", "self", ".", "metrics", "[", "'dia_exs'", "]", "if", "'feedback'", "in", "self", ".", "subtasks", "and", "self", ".", "metrics", "[", "'fee_exs'", "]", ">", "0", ":", "m", "[", "'fee_loss'", "]", "=", "self", ".", "metrics", "[", "'fee_loss'", "]", "/", "self", ".", "metrics", "[", "'fee_exs'", "]", "m", "[", "'fee_rank'", "]", "=", "self", ".", "metrics", "[", "'fee_rank'", "]", "/", "self", ".", "metrics", "[", "'fee_exs'", "]", "m", "[", "'fee_acc'", "]", "=", "self", ".", "metrics", "[", "'fee_correct'", "]", "/", "self", ".", "metrics", "[", "'fee_exs'", "]", "m", "[", "'fee_exs'", "]", "=", "self", ".", "metrics", "[", "'fee_exs'", "]", "m", "[", "'fee_exs'", "]", "=", "self", ".", "metrics", "[", "'fee_exs'", "]", "if", "'satisfaction'", "in", "self", ".", "subtasks", "and", "self", ".", "metrics", "[", "'sat_exs'", "]", ">", "0", ":", "tp", "=", "self", ".", "metrics", "[", "'sat_tp'", "]", "tn", "=", "self", ".", "metrics", "[", "'sat_tn'", "]", "fp", "=", "self", ".", "metrics", "[", "'sat_fp'", "]", "fn", "=", "self", ".", "metrics", "[", "'sat_fn'", "]", "assert", "tp", "+", "tn", "+", "fp", "+", "fn", "==", "self", ".", "metrics", "[", "'sat_exs'", "]", "m", "[", "'sat_loss'", "]", "=", "self", ".", "metrics", "[", "'sat_loss'", "]", "/", "self", ".", "metrics", "[", "'sat_exs'", "]", "m", "[", "'sat_pr'", "]", "=", "tp", "/", "(", "tp", "+", "fp", "+", "EPS", ")", "m", "[", "'sat_re'", "]", "=", "tp", "/", "(", "tp", "+", "fn", "+", "EPS", ")", "pr", "=", "m", "[", "'sat_pr'", "]", "re", "=", "m", "[", "'sat_re'", "]", "m", "[", "'sat_f1'", "]", "=", "(", "2", "*", "pr", "*", "re", ")", "/", "(", "pr", "+", "re", ")", "if", "(", "pr", "and", "re", ")", "else", "0.0", "m", "[", "'sat_acc'", "]", "=", "(", "tp", "+", "tn", ")", "/", "self", ".", "metrics", "[", "'sat_exs'", "]", "m", "[", "'sat_exs'", "]", "=", "self", ".", "metrics", "[", "'sat_exs'", "]", "for", "k", ",", "v", "in", "m", ".", "items", "(", ")", ":", "# clean up: rounds to sigfigs and converts tensors to floats", "if", "isinstance", "(", "v", ",", "float", ")", ":", "m", "[", "k", "]", "=", "round_sigfigs", "(", "v", ",", "4", ")", "else", ":", "m", "[", "k", "]", "=", "v", "return", "m" ]
[ 640, 4 ]
[ 679, 16 ]
python
en
['en', 'error', 'th']
False
SelfFeedingAgent.encode_candidates
(self, cands)
Encodes a tensor of vectorized candidates. :param cands: a [bs, seq_len] or [bs, num_cands, seq_len](?) of vectorized candidates
Encodes a tensor of vectorized candidates.
def encode_candidates(self, cands): """ Encodes a tensor of vectorized candidates. :param cands: a [bs, seq_len] or [bs, num_cands, seq_len](?) of vectorized candidates """ return self.model.encode_dia_y(cands)
[ "def", "encode_candidates", "(", "self", ",", "cands", ")", ":", "return", "self", ".", "model", ".", "encode_dia_y", "(", "cands", ")" ]
[ 681, 4 ]
[ 688, 45 ]
python
en
['en', 'error', 'th']
False
SelfFeedingAgent.do_request_feedback
(self, positivity)
Decide whether to request an feedback this turn.
Decide whether to request an feedback this turn.
def do_request_feedback(self, positivity): """ Decide whether to request an feedback this turn. """ # If --request-feedback=False, then don't request an feedback if not self.opt['request_feedback'] or len(self.history.history_strings) == 1: return False else: return positivity < self.opt['rating_threshold']
[ "def", "do_request_feedback", "(", "self", ",", "positivity", ")", ":", "# If --request-feedback=False, then don't request an feedback", "if", "not", "self", ".", "opt", "[", "'request_feedback'", "]", "or", "len", "(", "self", ".", "history", ".", "history_strings", ")", "==", "1", ":", "return", "False", "else", ":", "return", "positivity", "<", "self", ".", "opt", "[", "'rating_threshold'", "]" ]
[ 690, 4 ]
[ 698, 60 ]
python
en
['en', 'error', 'th']
False
SelfFeedingAgent.do_request_rating
(self, positivity)
Decide whether to request a rating this turn.
Decide whether to request a rating this turn.
def do_request_rating(self, positivity): """ Decide whether to request a rating this turn. """ # If --request-rating=False, then don't request a rating if not self.opt['request_rating']: return False # If no previous bot utterance is on record, can't ask about it elif len(self.history.history_strings) < 2: return False # Only request a rating a maximum of once per episode elif self.requested_rating: return False # Some percentage of the time, we ask for a rating randomly (to aid exploration) elif random.random() < self.opt['rating_frequency']: return True # Lastly, ask for a rating based on confidence (proximity to threshold) else: gap = abs(positivity - self.opt['rating_threshold']) return gap < self.opt['rating_gap']
[ "def", "do_request_rating", "(", "self", ",", "positivity", ")", ":", "# If --request-rating=False, then don't request a rating", "if", "not", "self", ".", "opt", "[", "'request_rating'", "]", ":", "return", "False", "# If no previous bot utterance is on record, can't ask about it", "elif", "len", "(", "self", ".", "history", ".", "history_strings", ")", "<", "2", ":", "return", "False", "# Only request a rating a maximum of once per episode", "elif", "self", ".", "requested_rating", ":", "return", "False", "# Some percentage of the time, we ask for a rating randomly (to aid exploration)", "elif", "random", ".", "random", "(", ")", "<", "self", ".", "opt", "[", "'rating_frequency'", "]", ":", "return", "True", "# Lastly, ask for a rating based on confidence (proximity to threshold)", "else", ":", "gap", "=", "abs", "(", "positivity", "-", "self", ".", "opt", "[", "'rating_threshold'", "]", ")", "return", "gap", "<", "self", ".", "opt", "[", "'rating_gap'", "]" ]
[ 700, 4 ]
[ 719, 47 ]
python
en
['en', 'error', 'th']
False
SelfFeedingAgent.extract_rating
(self)
Convert user response to rating request from text to an integer rating.
Convert user response to rating request from text to an integer rating.
def extract_rating(self): """ Convert user response to rating request from text to an integer rating. """ # TODO: Make this more robust! if self.last_rating == 'positive': return 1 elif self.last_rating == 'negative': return -1 else: return 0
[ "def", "extract_rating", "(", "self", ")", ":", "# TODO: Make this more robust!", "if", "self", ".", "last_rating", "==", "'positive'", ":", "return", "1", "elif", "self", ".", "last_rating", "==", "'negative'", ":", "return", "-", "1", "else", ":", "return", "0" ]
[ 721, 4 ]
[ 731, 20 ]
python
en
['en', 'error', 'th']
False
SelfFeedingAgent.load
(self, path)
Return opt and model states. Overriding TorchAgent.load() to enable partial loading
Return opt and model states.
def load(self, path): """ Return opt and model states. Overriding TorchAgent.load() to enable partial loading """ with PathManager.open(path, 'rb') as f: states = torch.load(f, map_location=lambda cpu, _: cpu) if 'model' in states: try: self.model.load_state_dict(states['model']) except RuntimeError as e: if self.opt['partial_load']: print( "WARNING: could not load entire --init-model; " "loading partially instead." ) pretrained_state = states['model'] current_state = self.model.state_dict() # 1. filter out unnecessary keys pretrained_dict = { k: v for k, v in pretrained_state.items() if k in current_state } # 2. overwrite entries in the existing state dict current_state.update(pretrained_dict) # 3. load the new state dict self.model.load_state_dict(current_state) else: raise Exception( f"The designated model could not be loaded. " f"Consider using --partial-load=True.\n {e}" ) if 'optimizer' in states and hasattr(self, 'optimizer'): self.optimizer.load_state_dict(states['optimizer']) return states
[ "def", "load", "(", "self", ",", "path", ")", ":", "with", "PathManager", ".", "open", "(", "path", ",", "'rb'", ")", "as", "f", ":", "states", "=", "torch", ".", "load", "(", "f", ",", "map_location", "=", "lambda", "cpu", ",", "_", ":", "cpu", ")", "if", "'model'", "in", "states", ":", "try", ":", "self", ".", "model", ".", "load_state_dict", "(", "states", "[", "'model'", "]", ")", "except", "RuntimeError", "as", "e", ":", "if", "self", ".", "opt", "[", "'partial_load'", "]", ":", "print", "(", "\"WARNING: could not load entire --init-model; \"", "\"loading partially instead.\"", ")", "pretrained_state", "=", "states", "[", "'model'", "]", "current_state", "=", "self", ".", "model", ".", "state_dict", "(", ")", "# 1. filter out unnecessary keys", "pretrained_dict", "=", "{", "k", ":", "v", "for", "k", ",", "v", "in", "pretrained_state", ".", "items", "(", ")", "if", "k", "in", "current_state", "}", "# 2. overwrite entries in the existing state dict", "current_state", ".", "update", "(", "pretrained_dict", ")", "# 3. load the new state dict", "self", ".", "model", ".", "load_state_dict", "(", "current_state", ")", "else", ":", "raise", "Exception", "(", "f\"The designated model could not be loaded. \"", "f\"Consider using --partial-load=True.\\n {e}\"", ")", "if", "'optimizer'", "in", "states", "and", "hasattr", "(", "self", ",", "'optimizer'", ")", ":", "self", ".", "optimizer", ".", "load_state_dict", "(", "states", "[", "'optimizer'", "]", ")", "return", "states" ]
[ 840, 4 ]
[ 875, 21 ]
python
en
['en', 'error', 'th']
False
main
(opt)
Extracts training data for the negative response classifier (NRC) from Mturk logs. input: file of logs (in ParlaiDialog format) from Mturk task 1 with turn-by-turn quality ratings 1-5 output: file of episodes (self-feeding format) w/ +1/-1 ratings indicating positive/negative example
Extracts training data for the negative response classifier (NRC) from Mturk logs.
def main(opt): """ Extracts training data for the negative response classifier (NRC) from Mturk logs. input: file of logs (in ParlaiDialog format) from Mturk task 1 with turn-by-turn quality ratings 1-5 output: file of episodes (self-feeding format) w/ +1/-1 ratings indicating positive/negative example """ examples = [] positives = opt['positives'].split(',') negatives = opt['negatives'].split(',') assert len(set(positives).intersection(set(negatives))) == 0 num_episodes = 0 num_parleys = 0 for episode in extract_parlai_episodes(opt['infile']): num_episodes += 1 history = [] for parley in episode: num_parleys += 1 # Update history (not including stock control flow responses) if parley.context.startswith(INITIAL_PROMPT): # Conversation prompt, first utterance # Begin history history = [parley.response] elif parley.context.startswith(EXP_REQUEST): # Asked for y_exp, got y_exp # Messed up, so blast history example = Parley( context=add_person_tokens(history[:-2], last_speaker=1), response=parley.response, # y_exp ) examples.append(example) history = [] elif parley.context.startswith(NEWTOPIC): # Asked for new topic, got a first utterance # Begin new history history = [parley.response] elif parley.context.startswith(RAT_REQUEST): # Asked for rating, got one-word rating # Nothing to update in history pass elif CONTINUE in parley.context: # if response was negative, history will get blasted in EXP_REQUEST # if we're here, response was neutral/positive, so continue the history history.append(parley.context[parley.context.rindex(':') + 1 :]) history.append(parley.response) else: # normal turn: maintain the history history.append(parley.context) history.append(parley.response) with PathManager.open(opt['outfile'], 'w') as outfile: for ex in examples: outfile.write(json.dumps(ex.to_dict()) + '\n') print( f"Extracted {len(examples)} ratings out of {num_episodes} episodes " f"({num_parleys} parleys) and wrote them to {opt['outfile']} with " f"histsz == {opt['history_size']}." )
[ "def", "main", "(", "opt", ")", ":", "examples", "=", "[", "]", "positives", "=", "opt", "[", "'positives'", "]", ".", "split", "(", "','", ")", "negatives", "=", "opt", "[", "'negatives'", "]", ".", "split", "(", "','", ")", "assert", "len", "(", "set", "(", "positives", ")", ".", "intersection", "(", "set", "(", "negatives", ")", ")", ")", "==", "0", "num_episodes", "=", "0", "num_parleys", "=", "0", "for", "episode", "in", "extract_parlai_episodes", "(", "opt", "[", "'infile'", "]", ")", ":", "num_episodes", "+=", "1", "history", "=", "[", "]", "for", "parley", "in", "episode", ":", "num_parleys", "+=", "1", "# Update history (not including stock control flow responses)", "if", "parley", ".", "context", ".", "startswith", "(", "INITIAL_PROMPT", ")", ":", "# Conversation prompt, first utterance", "# Begin history", "history", "=", "[", "parley", ".", "response", "]", "elif", "parley", ".", "context", ".", "startswith", "(", "EXP_REQUEST", ")", ":", "# Asked for y_exp, got y_exp", "# Messed up, so blast history", "example", "=", "Parley", "(", "context", "=", "add_person_tokens", "(", "history", "[", ":", "-", "2", "]", ",", "last_speaker", "=", "1", ")", ",", "response", "=", "parley", ".", "response", ",", "# y_exp", ")", "examples", ".", "append", "(", "example", ")", "history", "=", "[", "]", "elif", "parley", ".", "context", ".", "startswith", "(", "NEWTOPIC", ")", ":", "# Asked for new topic, got a first utterance", "# Begin new history", "history", "=", "[", "parley", ".", "response", "]", "elif", "parley", ".", "context", ".", "startswith", "(", "RAT_REQUEST", ")", ":", "# Asked for rating, got one-word rating", "# Nothing to update in history", "pass", "elif", "CONTINUE", "in", "parley", ".", "context", ":", "# if response was negative, history will get blasted in EXP_REQUEST", "# if we're here, response was neutral/positive, so continue the history", "history", ".", "append", "(", "parley", ".", "context", "[", "parley", ".", "context", ".", "rindex", "(", "':'", ")", "+", "1", ":", "]", ")", "history", ".", "append", "(", "parley", ".", "response", ")", "else", ":", "# normal turn: maintain the history", "history", ".", "append", "(", "parley", ".", "context", ")", "history", ".", "append", "(", "parley", ".", "response", ")", "with", "PathManager", ".", "open", "(", "opt", "[", "'outfile'", "]", ",", "'w'", ")", "as", "outfile", ":", "for", "ex", "in", "examples", ":", "outfile", ".", "write", "(", "json", ".", "dumps", "(", "ex", ".", "to_dict", "(", ")", ")", "+", "'\\n'", ")", "print", "(", "f\"Extracted {len(examples)} ratings out of {num_episodes} episodes \"", "f\"({num_parleys} parleys) and wrote them to {opt['outfile']} with \"", "f\"histsz == {opt['history_size']}.\"", ")" ]
[ 53, 0 ]
[ 115, 5 ]
python
en
['en', 'error', 'th']
False
ColorBar.bgcolor
(self)
Sets the color of padded area. The 'bgcolor' 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: aliceblue, antiquewhite, aqua, aquamarine, azure, beige, bisque, black, blanchedalmond, blue, blueviolet, brown, burlywood, cadetblue, chartreuse, chocolate, coral, cornflowerblue, cornsilk, crimson, cyan, darkblue, darkcyan, darkgoldenrod, darkgray, darkgrey, darkgreen, darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred, darksalmon, darkseagreen, darkslateblue, darkslategray, darkslategrey, darkturquoise, darkviolet, deeppink, deepskyblue, dimgray, dimgrey, dodgerblue, firebrick, floralwhite, forestgreen, fuchsia, gainsboro, ghostwhite, gold, goldenrod, gray, grey, green, greenyellow, honeydew, hotpink, indianred, indigo, ivory, khaki, lavender, lavenderblush, lawngreen, lemonchiffon, lightblue, lightcoral, lightcyan, lightgoldenrodyellow, lightgray, lightgrey, lightgreen, lightpink, lightsalmon, lightseagreen, lightskyblue, lightslategray, lightslategrey, lightsteelblue, lightyellow, lime, limegreen, linen, magenta, maroon, mediumaquamarine, mediumblue, mediumorchid, mediumpurple, mediumseagreen, mediumslateblue, mediumspringgreen, mediumturquoise, mediumvioletred, midnightblue, mintcream, mistyrose, moccasin, navajowhite, navy, oldlace, olive, olivedrab, orange, orangered, orchid, palegoldenrod, palegreen, paleturquoise, palevioletred, papayawhip, peachpuff, peru, pink, plum, powderblue, purple, red, rosybrown, royalblue, rebeccapurple, saddlebrown, salmon, sandybrown, seagreen, seashell, sienna, silver, skyblue, slateblue, slategray, slategrey, snow, springgreen, steelblue, tan, teal, thistle, tomato, turquoise, violet, wheat, white, whitesmoke, yellow, yellowgreen Returns ------- str
Sets the color of padded area. The 'bgcolor' 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: aliceblue, antiquewhite, aqua, aquamarine, azure, beige, bisque, black, blanchedalmond, blue, blueviolet, brown, burlywood, cadetblue, chartreuse, chocolate, coral, cornflowerblue, cornsilk, crimson, cyan, darkblue, darkcyan, darkgoldenrod, darkgray, darkgrey, darkgreen, darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred, darksalmon, darkseagreen, darkslateblue, darkslategray, darkslategrey, darkturquoise, darkviolet, deeppink, deepskyblue, dimgray, dimgrey, dodgerblue, firebrick, floralwhite, forestgreen, fuchsia, gainsboro, ghostwhite, gold, goldenrod, gray, grey, green, greenyellow, honeydew, hotpink, indianred, indigo, ivory, khaki, lavender, lavenderblush, lawngreen, lemonchiffon, lightblue, lightcoral, lightcyan, lightgoldenrodyellow, lightgray, lightgrey, lightgreen, lightpink, lightsalmon, lightseagreen, lightskyblue, lightslategray, lightslategrey, lightsteelblue, lightyellow, lime, limegreen, linen, magenta, maroon, mediumaquamarine, mediumblue, mediumorchid, mediumpurple, mediumseagreen, mediumslateblue, mediumspringgreen, mediumturquoise, mediumvioletred, midnightblue, mintcream, mistyrose, moccasin, navajowhite, navy, oldlace, olive, olivedrab, orange, orangered, orchid, palegoldenrod, palegreen, paleturquoise, palevioletred, papayawhip, peachpuff, peru, pink, plum, powderblue, purple, red, rosybrown, royalblue, rebeccapurple, saddlebrown, salmon, sandybrown, seagreen, seashell, sienna, silver, skyblue, slateblue, slategray, slategrey, snow, springgreen, steelblue, tan, teal, thistle, tomato, turquoise, violet, wheat, white, whitesmoke, yellow, yellowgreen
def bgcolor(self): """ Sets the color of padded area. The 'bgcolor' 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: aliceblue, antiquewhite, aqua, aquamarine, azure, beige, bisque, black, blanchedalmond, blue, blueviolet, brown, burlywood, cadetblue, chartreuse, chocolate, coral, cornflowerblue, cornsilk, crimson, cyan, darkblue, darkcyan, darkgoldenrod, darkgray, darkgrey, darkgreen, darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred, darksalmon, darkseagreen, darkslateblue, darkslategray, darkslategrey, darkturquoise, darkviolet, deeppink, deepskyblue, dimgray, dimgrey, dodgerblue, firebrick, floralwhite, forestgreen, fuchsia, gainsboro, ghostwhite, gold, goldenrod, gray, grey, green, greenyellow, honeydew, hotpink, indianred, indigo, ivory, khaki, lavender, lavenderblush, lawngreen, lemonchiffon, lightblue, lightcoral, lightcyan, lightgoldenrodyellow, lightgray, lightgrey, lightgreen, lightpink, lightsalmon, lightseagreen, lightskyblue, lightslategray, lightslategrey, lightsteelblue, lightyellow, lime, limegreen, linen, magenta, maroon, mediumaquamarine, mediumblue, mediumorchid, mediumpurple, mediumseagreen, mediumslateblue, mediumspringgreen, mediumturquoise, mediumvioletred, midnightblue, mintcream, mistyrose, moccasin, navajowhite, navy, oldlace, olive, olivedrab, orange, orangered, orchid, palegoldenrod, palegreen, paleturquoise, palevioletred, papayawhip, peachpuff, peru, pink, plum, powderblue, purple, red, rosybrown, royalblue, rebeccapurple, saddlebrown, salmon, sandybrown, seagreen, seashell, sienna, silver, skyblue, slateblue, slategray, slategrey, snow, springgreen, steelblue, tan, teal, thistle, tomato, turquoise, violet, wheat, white, whitesmoke, yellow, yellowgreen Returns ------- str """ return self["bgcolor"]
[ "def", "bgcolor", "(", "self", ")", ":", "return", "self", "[", "\"bgcolor\"", "]" ]
[ 59, 4 ]
[ 109, 30 ]
python
en
['en', 'error', 'th']
False
ColorBar.bordercolor
(self)
Sets the axis line color. The 'bordercolor' 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: aliceblue, antiquewhite, aqua, aquamarine, azure, beige, bisque, black, blanchedalmond, blue, blueviolet, brown, burlywood, cadetblue, chartreuse, chocolate, coral, cornflowerblue, cornsilk, crimson, cyan, darkblue, darkcyan, darkgoldenrod, darkgray, darkgrey, darkgreen, darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred, darksalmon, darkseagreen, darkslateblue, darkslategray, darkslategrey, darkturquoise, darkviolet, deeppink, deepskyblue, dimgray, dimgrey, dodgerblue, firebrick, floralwhite, forestgreen, fuchsia, gainsboro, ghostwhite, gold, goldenrod, gray, grey, green, greenyellow, honeydew, hotpink, indianred, indigo, ivory, khaki, lavender, lavenderblush, lawngreen, lemonchiffon, lightblue, lightcoral, lightcyan, lightgoldenrodyellow, lightgray, lightgrey, lightgreen, lightpink, lightsalmon, lightseagreen, lightskyblue, lightslategray, lightslategrey, lightsteelblue, lightyellow, lime, limegreen, linen, magenta, maroon, mediumaquamarine, mediumblue, mediumorchid, mediumpurple, mediumseagreen, mediumslateblue, mediumspringgreen, mediumturquoise, mediumvioletred, midnightblue, mintcream, mistyrose, moccasin, navajowhite, navy, oldlace, olive, olivedrab, orange, orangered, orchid, palegoldenrod, palegreen, paleturquoise, palevioletred, papayawhip, peachpuff, peru, pink, plum, powderblue, purple, red, rosybrown, royalblue, rebeccapurple, saddlebrown, salmon, sandybrown, seagreen, seashell, sienna, silver, skyblue, slateblue, slategray, slategrey, snow, springgreen, steelblue, tan, teal, thistle, tomato, turquoise, violet, wheat, white, whitesmoke, yellow, yellowgreen Returns ------- str
Sets the axis line color. The 'bordercolor' 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: aliceblue, antiquewhite, aqua, aquamarine, azure, beige, bisque, black, blanchedalmond, blue, blueviolet, brown, burlywood, cadetblue, chartreuse, chocolate, coral, cornflowerblue, cornsilk, crimson, cyan, darkblue, darkcyan, darkgoldenrod, darkgray, darkgrey, darkgreen, darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred, darksalmon, darkseagreen, darkslateblue, darkslategray, darkslategrey, darkturquoise, darkviolet, deeppink, deepskyblue, dimgray, dimgrey, dodgerblue, firebrick, floralwhite, forestgreen, fuchsia, gainsboro, ghostwhite, gold, goldenrod, gray, grey, green, greenyellow, honeydew, hotpink, indianred, indigo, ivory, khaki, lavender, lavenderblush, lawngreen, lemonchiffon, lightblue, lightcoral, lightcyan, lightgoldenrodyellow, lightgray, lightgrey, lightgreen, lightpink, lightsalmon, lightseagreen, lightskyblue, lightslategray, lightslategrey, lightsteelblue, lightyellow, lime, limegreen, linen, magenta, maroon, mediumaquamarine, mediumblue, mediumorchid, mediumpurple, mediumseagreen, mediumslateblue, mediumspringgreen, mediumturquoise, mediumvioletred, midnightblue, mintcream, mistyrose, moccasin, navajowhite, navy, oldlace, olive, olivedrab, orange, orangered, orchid, palegoldenrod, palegreen, paleturquoise, palevioletred, papayawhip, peachpuff, peru, pink, plum, powderblue, purple, red, rosybrown, royalblue, rebeccapurple, saddlebrown, salmon, sandybrown, seagreen, seashell, sienna, silver, skyblue, slateblue, slategray, slategrey, snow, springgreen, steelblue, tan, teal, thistle, tomato, turquoise, violet, wheat, white, whitesmoke, yellow, yellowgreen
def bordercolor(self): """ Sets the axis line color. The 'bordercolor' 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: aliceblue, antiquewhite, aqua, aquamarine, azure, beige, bisque, black, blanchedalmond, blue, blueviolet, brown, burlywood, cadetblue, chartreuse, chocolate, coral, cornflowerblue, cornsilk, crimson, cyan, darkblue, darkcyan, darkgoldenrod, darkgray, darkgrey, darkgreen, darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred, darksalmon, darkseagreen, darkslateblue, darkslategray, darkslategrey, darkturquoise, darkviolet, deeppink, deepskyblue, dimgray, dimgrey, dodgerblue, firebrick, floralwhite, forestgreen, fuchsia, gainsboro, ghostwhite, gold, goldenrod, gray, grey, green, greenyellow, honeydew, hotpink, indianred, indigo, ivory, khaki, lavender, lavenderblush, lawngreen, lemonchiffon, lightblue, lightcoral, lightcyan, lightgoldenrodyellow, lightgray, lightgrey, lightgreen, lightpink, lightsalmon, lightseagreen, lightskyblue, lightslategray, lightslategrey, lightsteelblue, lightyellow, lime, limegreen, linen, magenta, maroon, mediumaquamarine, mediumblue, mediumorchid, mediumpurple, mediumseagreen, mediumslateblue, mediumspringgreen, mediumturquoise, mediumvioletred, midnightblue, mintcream, mistyrose, moccasin, navajowhite, navy, oldlace, olive, olivedrab, orange, orangered, orchid, palegoldenrod, palegreen, paleturquoise, palevioletred, papayawhip, peachpuff, peru, pink, plum, powderblue, purple, red, rosybrown, royalblue, rebeccapurple, saddlebrown, salmon, sandybrown, seagreen, seashell, sienna, silver, skyblue, slateblue, slategray, slategrey, snow, springgreen, steelblue, tan, teal, thistle, tomato, turquoise, violet, wheat, white, whitesmoke, yellow, yellowgreen Returns ------- str """ return self["bordercolor"]
[ "def", "bordercolor", "(", "self", ")", ":", "return", "self", "[", "\"bordercolor\"", "]" ]
[ 118, 4 ]
[ 168, 34 ]
python
en
['en', 'error', 'th']
False
ColorBar.borderwidth
(self)
Sets the width (in px) or the border enclosing this color bar. The 'borderwidth' property is a number and may be specified as: - An int or float in the interval [0, inf] Returns ------- int|float
Sets the width (in px) or the border enclosing this color bar. The 'borderwidth' property is a number and may be specified as: - An int or float in the interval [0, inf]
def borderwidth(self): """ Sets the width (in px) or the border enclosing this color bar. The 'borderwidth' property is a number and may be specified as: - An int or float in the interval [0, inf] Returns ------- int|float """ return self["borderwidth"]
[ "def", "borderwidth", "(", "self", ")", ":", "return", "self", "[", "\"borderwidth\"", "]" ]
[ 177, 4 ]
[ 188, 34 ]
python
en
['en', 'error', 'th']
False
ColorBar.dtick
(self)
Sets the step in-between ticks on this axis. Use with `tick0`. Must be a positive number, or special strings available to "log" and "date" axes. If the axis `type` is "log", then ticks are set every 10^(n*dtick) where n is the tick number. For example, to set a tick mark at 1, 10, 100, 1000, ... set dtick to 1. To set tick marks at 1, 100, 10000, ... set dtick to 2. To set tick marks at 1, 5, 25, 125, 625, 3125, ... set dtick to log_10(5), or 0.69897000433. "log" has several special values; "L<f>", where `f` is a positive number, gives ticks linearly spaced in value (but not position). For example `tick0` = 0.1, `dtick` = "L0.5" will put ticks at 0.1, 0.6, 1.1, 1.6 etc. To show powers of 10 plus small digits between, use "D1" (all digits) or "D2" (only 2 and 5). `tick0` is ignored for "D1" and "D2". If the axis `type` is "date", then you must convert the time to milliseconds. For example, to set the interval between ticks to one day, set `dtick` to 86400000.0. "date" also has special values "M<n>" gives ticks spaced by a number of months. `n` must be a positive integer. To set ticks on the 15th of every third month, set `tick0` to "2000-01-15" and `dtick` to "M3". To set ticks every 4 years, set `dtick` to "M48" The 'dtick' property accepts values of any type Returns ------- Any
Sets the step in-between ticks on this axis. Use with `tick0`. Must be a positive number, or special strings available to "log" and "date" axes. If the axis `type` is "log", then ticks are set every 10^(n*dtick) where n is the tick number. For example, to set a tick mark at 1, 10, 100, 1000, ... set dtick to 1. To set tick marks at 1, 100, 10000, ... set dtick to 2. To set tick marks at 1, 5, 25, 125, 625, 3125, ... set dtick to log_10(5), or 0.69897000433. "log" has several special values; "L<f>", where `f` is a positive number, gives ticks linearly spaced in value (but not position). For example `tick0` = 0.1, `dtick` = "L0.5" will put ticks at 0.1, 0.6, 1.1, 1.6 etc. To show powers of 10 plus small digits between, use "D1" (all digits) or "D2" (only 2 and 5). `tick0` is ignored for "D1" and "D2". If the axis `type` is "date", then you must convert the time to milliseconds. For example, to set the interval between ticks to one day, set `dtick` to 86400000.0. "date" also has special values "M<n>" gives ticks spaced by a number of months. `n` must be a positive integer. To set ticks on the 15th of every third month, set `tick0` to "2000-01-15" and `dtick` to "M3". To set ticks every 4 years, set `dtick` to "M48" The 'dtick' property accepts values of any type
def dtick(self): """ Sets the step in-between ticks on this axis. Use with `tick0`. Must be a positive number, or special strings available to "log" and "date" axes. If the axis `type` is "log", then ticks are set every 10^(n*dtick) where n is the tick number. For example, to set a tick mark at 1, 10, 100, 1000, ... set dtick to 1. To set tick marks at 1, 100, 10000, ... set dtick to 2. To set tick marks at 1, 5, 25, 125, 625, 3125, ... set dtick to log_10(5), or 0.69897000433. "log" has several special values; "L<f>", where `f` is a positive number, gives ticks linearly spaced in value (but not position). For example `tick0` = 0.1, `dtick` = "L0.5" will put ticks at 0.1, 0.6, 1.1, 1.6 etc. To show powers of 10 plus small digits between, use "D1" (all digits) or "D2" (only 2 and 5). `tick0` is ignored for "D1" and "D2". If the axis `type` is "date", then you must convert the time to milliseconds. For example, to set the interval between ticks to one day, set `dtick` to 86400000.0. "date" also has special values "M<n>" gives ticks spaced by a number of months. `n` must be a positive integer. To set ticks on the 15th of every third month, set `tick0` to "2000-01-15" and `dtick` to "M3". To set ticks every 4 years, set `dtick` to "M48" The 'dtick' property accepts values of any type Returns ------- Any """ return self["dtick"]
[ "def", "dtick", "(", "self", ")", ":", "return", "self", "[", "\"dtick\"", "]" ]
[ 197, 4 ]
[ 226, 28 ]
python
en
['en', 'error', 'th']
False
ColorBar.exponentformat
(self)
Determines a formatting rule for the tick exponents. For example, consider the number 1,000,000,000. If "none", it appears as 1,000,000,000. If "e", 1e+9. If "E", 1E+9. If "power", 1x10^9 (with 9 in a super script). If "SI", 1G. If "B", 1B. The 'exponentformat' property is an enumeration that may be specified as: - One of the following enumeration values: ['none', 'e', 'E', 'power', 'SI', 'B'] Returns ------- Any
Determines a formatting rule for the tick exponents. For example, consider the number 1,000,000,000. If "none", it appears as 1,000,000,000. If "e", 1e+9. If "E", 1E+9. If "power", 1x10^9 (with 9 in a super script). If "SI", 1G. If "B", 1B. The 'exponentformat' property is an enumeration that may be specified as: - One of the following enumeration values: ['none', 'e', 'E', 'power', 'SI', 'B']
def exponentformat(self): """ Determines a formatting rule for the tick exponents. For example, consider the number 1,000,000,000. If "none", it appears as 1,000,000,000. If "e", 1e+9. If "E", 1E+9. If "power", 1x10^9 (with 9 in a super script). If "SI", 1G. If "B", 1B. The 'exponentformat' property is an enumeration that may be specified as: - One of the following enumeration values: ['none', 'e', 'E', 'power', 'SI', 'B'] Returns ------- Any """ return self["exponentformat"]
[ "def", "exponentformat", "(", "self", ")", ":", "return", "self", "[", "\"exponentformat\"", "]" ]
[ 235, 4 ]
[ 251, 37 ]
python
en
['en', 'error', 'th']
False
ColorBar.len
(self)
Sets the length of the color bar This measure excludes the padding of both ends. That is, the color bar length is this length minus the padding on both ends. The 'len' property is a number and may be specified as: - An int or float in the interval [0, inf] Returns ------- int|float
Sets the length of the color bar This measure excludes the padding of both ends. That is, the color bar length is this length minus the padding on both ends. The 'len' property is a number and may be specified as: - An int or float in the interval [0, inf]
def len(self): """ Sets the length of the color bar This measure excludes the padding of both ends. That is, the color bar length is this length minus the padding on both ends. The 'len' property is a number and may be specified as: - An int or float in the interval [0, inf] Returns ------- int|float """ return self["len"]
[ "def", "len", "(", "self", ")", ":", "return", "self", "[", "\"len\"", "]" ]
[ 260, 4 ]
[ 273, 26 ]
python
en
['en', 'error', 'th']
False
ColorBar.lenmode
(self)
Determines whether this color bar's length (i.e. the measure in the color variation direction) is set in units of plot "fraction" or in *pixels. Use `len` to set the value. The 'lenmode' property is an enumeration that may be specified as: - One of the following enumeration values: ['fraction', 'pixels'] Returns ------- Any
Determines whether this color bar's length (i.e. the measure in the color variation direction) is set in units of plot "fraction" or in *pixels. Use `len` to set the value. The 'lenmode' property is an enumeration that may be specified as: - One of the following enumeration values: ['fraction', 'pixels']
def lenmode(self): """ Determines whether this color bar's length (i.e. the measure in the color variation direction) is set in units of plot "fraction" or in *pixels. Use `len` to set the value. The 'lenmode' property is an enumeration that may be specified as: - One of the following enumeration values: ['fraction', 'pixels'] Returns ------- Any """ return self["lenmode"]
[ "def", "lenmode", "(", "self", ")", ":", "return", "self", "[", "\"lenmode\"", "]" ]
[ 282, 4 ]
[ 296, 30 ]
python
en
['en', 'error', 'th']
False
ColorBar.nticks
(self)
Specifies the maximum number of ticks for the particular axis. The actual number of ticks will be chosen automatically to be less than or equal to `nticks`. Has an effect only if `tickmode` is set to "auto". The 'nticks' property is a integer and may be specified as: - An int (or float that will be cast to an int) in the interval [0, 9223372036854775807] Returns ------- int
Specifies the maximum number of ticks for the particular axis. The actual number of ticks will be chosen automatically to be less than or equal to `nticks`. Has an effect only if `tickmode` is set to "auto". The 'nticks' property is a integer and may be specified as: - An int (or float that will be cast to an int) in the interval [0, 9223372036854775807]
def nticks(self): """ Specifies the maximum number of ticks for the particular axis. The actual number of ticks will be chosen automatically to be less than or equal to `nticks`. Has an effect only if `tickmode` is set to "auto". The 'nticks' property is a integer and may be specified as: - An int (or float that will be cast to an int) in the interval [0, 9223372036854775807] Returns ------- int """ return self["nticks"]
[ "def", "nticks", "(", "self", ")", ":", "return", "self", "[", "\"nticks\"", "]" ]
[ 305, 4 ]
[ 320, 29 ]
python
en
['en', 'error', 'th']
False
ColorBar.outlinecolor
(self)
Sets the axis line color. The 'outlinecolor' 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: aliceblue, antiquewhite, aqua, aquamarine, azure, beige, bisque, black, blanchedalmond, blue, blueviolet, brown, burlywood, cadetblue, chartreuse, chocolate, coral, cornflowerblue, cornsilk, crimson, cyan, darkblue, darkcyan, darkgoldenrod, darkgray, darkgrey, darkgreen, darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred, darksalmon, darkseagreen, darkslateblue, darkslategray, darkslategrey, darkturquoise, darkviolet, deeppink, deepskyblue, dimgray, dimgrey, dodgerblue, firebrick, floralwhite, forestgreen, fuchsia, gainsboro, ghostwhite, gold, goldenrod, gray, grey, green, greenyellow, honeydew, hotpink, indianred, indigo, ivory, khaki, lavender, lavenderblush, lawngreen, lemonchiffon, lightblue, lightcoral, lightcyan, lightgoldenrodyellow, lightgray, lightgrey, lightgreen, lightpink, lightsalmon, lightseagreen, lightskyblue, lightslategray, lightslategrey, lightsteelblue, lightyellow, lime, limegreen, linen, magenta, maroon, mediumaquamarine, mediumblue, mediumorchid, mediumpurple, mediumseagreen, mediumslateblue, mediumspringgreen, mediumturquoise, mediumvioletred, midnightblue, mintcream, mistyrose, moccasin, navajowhite, navy, oldlace, olive, olivedrab, orange, orangered, orchid, palegoldenrod, palegreen, paleturquoise, palevioletred, papayawhip, peachpuff, peru, pink, plum, powderblue, purple, red, rosybrown, royalblue, rebeccapurple, saddlebrown, salmon, sandybrown, seagreen, seashell, sienna, silver, skyblue, slateblue, slategray, slategrey, snow, springgreen, steelblue, tan, teal, thistle, tomato, turquoise, violet, wheat, white, whitesmoke, yellow, yellowgreen Returns ------- str
Sets the axis line color. The 'outlinecolor' 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: aliceblue, antiquewhite, aqua, aquamarine, azure, beige, bisque, black, blanchedalmond, blue, blueviolet, brown, burlywood, cadetblue, chartreuse, chocolate, coral, cornflowerblue, cornsilk, crimson, cyan, darkblue, darkcyan, darkgoldenrod, darkgray, darkgrey, darkgreen, darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred, darksalmon, darkseagreen, darkslateblue, darkslategray, darkslategrey, darkturquoise, darkviolet, deeppink, deepskyblue, dimgray, dimgrey, dodgerblue, firebrick, floralwhite, forestgreen, fuchsia, gainsboro, ghostwhite, gold, goldenrod, gray, grey, green, greenyellow, honeydew, hotpink, indianred, indigo, ivory, khaki, lavender, lavenderblush, lawngreen, lemonchiffon, lightblue, lightcoral, lightcyan, lightgoldenrodyellow, lightgray, lightgrey, lightgreen, lightpink, lightsalmon, lightseagreen, lightskyblue, lightslategray, lightslategrey, lightsteelblue, lightyellow, lime, limegreen, linen, magenta, maroon, mediumaquamarine, mediumblue, mediumorchid, mediumpurple, mediumseagreen, mediumslateblue, mediumspringgreen, mediumturquoise, mediumvioletred, midnightblue, mintcream, mistyrose, moccasin, navajowhite, navy, oldlace, olive, olivedrab, orange, orangered, orchid, palegoldenrod, palegreen, paleturquoise, palevioletred, papayawhip, peachpuff, peru, pink, plum, powderblue, purple, red, rosybrown, royalblue, rebeccapurple, saddlebrown, salmon, sandybrown, seagreen, seashell, sienna, silver, skyblue, slateblue, slategray, slategrey, snow, springgreen, steelblue, tan, teal, thistle, tomato, turquoise, violet, wheat, white, whitesmoke, yellow, yellowgreen
def outlinecolor(self): """ Sets the axis line color. The 'outlinecolor' 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: aliceblue, antiquewhite, aqua, aquamarine, azure, beige, bisque, black, blanchedalmond, blue, blueviolet, brown, burlywood, cadetblue, chartreuse, chocolate, coral, cornflowerblue, cornsilk, crimson, cyan, darkblue, darkcyan, darkgoldenrod, darkgray, darkgrey, darkgreen, darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred, darksalmon, darkseagreen, darkslateblue, darkslategray, darkslategrey, darkturquoise, darkviolet, deeppink, deepskyblue, dimgray, dimgrey, dodgerblue, firebrick, floralwhite, forestgreen, fuchsia, gainsboro, ghostwhite, gold, goldenrod, gray, grey, green, greenyellow, honeydew, hotpink, indianred, indigo, ivory, khaki, lavender, lavenderblush, lawngreen, lemonchiffon, lightblue, lightcoral, lightcyan, lightgoldenrodyellow, lightgray, lightgrey, lightgreen, lightpink, lightsalmon, lightseagreen, lightskyblue, lightslategray, lightslategrey, lightsteelblue, lightyellow, lime, limegreen, linen, magenta, maroon, mediumaquamarine, mediumblue, mediumorchid, mediumpurple, mediumseagreen, mediumslateblue, mediumspringgreen, mediumturquoise, mediumvioletred, midnightblue, mintcream, mistyrose, moccasin, navajowhite, navy, oldlace, olive, olivedrab, orange, orangered, orchid, palegoldenrod, palegreen, paleturquoise, palevioletred, papayawhip, peachpuff, peru, pink, plum, powderblue, purple, red, rosybrown, royalblue, rebeccapurple, saddlebrown, salmon, sandybrown, seagreen, seashell, sienna, silver, skyblue, slateblue, slategray, slategrey, snow, springgreen, steelblue, tan, teal, thistle, tomato, turquoise, violet, wheat, white, whitesmoke, yellow, yellowgreen Returns ------- str """ return self["outlinecolor"]
[ "def", "outlinecolor", "(", "self", ")", ":", "return", "self", "[", "\"outlinecolor\"", "]" ]
[ 329, 4 ]
[ 379, 35 ]
python
en
['en', 'error', 'th']
False
ColorBar.outlinewidth
(self)
Sets the width (in px) of the axis line. The 'outlinewidth' property is a number and may be specified as: - An int or float in the interval [0, inf] Returns ------- int|float
Sets the width (in px) of the axis line. The 'outlinewidth' property is a number and may be specified as: - An int or float in the interval [0, inf]
def outlinewidth(self): """ Sets the width (in px) of the axis line. The 'outlinewidth' property is a number and may be specified as: - An int or float in the interval [0, inf] Returns ------- int|float """ return self["outlinewidth"]
[ "def", "outlinewidth", "(", "self", ")", ":", "return", "self", "[", "\"outlinewidth\"", "]" ]
[ 388, 4 ]
[ 399, 35 ]
python
en
['en', 'error', 'th']
False
ColorBar.separatethousands
(self)
If "true", even 4-digit integers are separated The 'separatethousands' property must be specified as a bool (either True, or False) Returns ------- bool
If "true", even 4-digit integers are separated The 'separatethousands' property must be specified as a bool (either True, or False)
def separatethousands(self): """ If "true", even 4-digit integers are separated The 'separatethousands' property must be specified as a bool (either True, or False) Returns ------- bool """ return self["separatethousands"]
[ "def", "separatethousands", "(", "self", ")", ":", "return", "self", "[", "\"separatethousands\"", "]" ]
[ 408, 4 ]
[ 419, 40 ]
python
en
['en', 'error', 'th']
False
ColorBar.showexponent
(self)
If "all", all exponents are shown besides their significands. If "first", only the exponent of the first tick is shown. If "last", only the exponent of the last tick is shown. If "none", no exponents appear. The 'showexponent' property is an enumeration that may be specified as: - One of the following enumeration values: ['all', 'first', 'last', 'none'] Returns ------- Any
If "all", all exponents are shown besides their significands. If "first", only the exponent of the first tick is shown. If "last", only the exponent of the last tick is shown. If "none", no exponents appear. The 'showexponent' property is an enumeration that may be specified as: - One of the following enumeration values: ['all', 'first', 'last', 'none']
def showexponent(self): """ If "all", all exponents are shown besides their significands. If "first", only the exponent of the first tick is shown. If "last", only the exponent of the last tick is shown. If "none", no exponents appear. The 'showexponent' property is an enumeration that may be specified as: - One of the following enumeration values: ['all', 'first', 'last', 'none'] Returns ------- Any """ return self["showexponent"]
[ "def", "showexponent", "(", "self", ")", ":", "return", "self", "[", "\"showexponent\"", "]" ]
[ 428, 4 ]
[ 443, 35 ]
python
en
['en', 'error', 'th']
False
ColorBar.showticklabels
(self)
Determines whether or not the tick labels are drawn. The 'showticklabels' property must be specified as a bool (either True, or False) Returns ------- bool
Determines whether or not the tick labels are drawn. The 'showticklabels' property must be specified as a bool (either True, or False)
def showticklabels(self): """ Determines whether or not the tick labels are drawn. The 'showticklabels' property must be specified as a bool (either True, or False) Returns ------- bool """ return self["showticklabels"]
[ "def", "showticklabels", "(", "self", ")", ":", "return", "self", "[", "\"showticklabels\"", "]" ]
[ 452, 4 ]
[ 463, 37 ]
python
en
['en', 'error', 'th']
False
ColorBar.showtickprefix
(self)
If "all", all tick labels are displayed with a prefix. If "first", only the first tick is displayed with a prefix. If "last", only the last tick is displayed with a suffix. If "none", tick prefixes are hidden. The 'showtickprefix' property is an enumeration that may be specified as: - One of the following enumeration values: ['all', 'first', 'last', 'none'] Returns ------- Any
If "all", all tick labels are displayed with a prefix. If "first", only the first tick is displayed with a prefix. If "last", only the last tick is displayed with a suffix. If "none", tick prefixes are hidden. The 'showtickprefix' property is an enumeration that may be specified as: - One of the following enumeration values: ['all', 'first', 'last', 'none']
def showtickprefix(self): """ If "all", all tick labels are displayed with a prefix. If "first", only the first tick is displayed with a prefix. If "last", only the last tick is displayed with a suffix. If "none", tick prefixes are hidden. The 'showtickprefix' property is an enumeration that may be specified as: - One of the following enumeration values: ['all', 'first', 'last', 'none'] Returns ------- Any """ return self["showtickprefix"]
[ "def", "showtickprefix", "(", "self", ")", ":", "return", "self", "[", "\"showtickprefix\"", "]" ]
[ 472, 4 ]
[ 487, 37 ]
python
en
['en', 'error', 'th']
False
ColorBar.showticksuffix
(self)
Same as `showtickprefix` but for tick suffixes. The 'showticksuffix' property is an enumeration that may be specified as: - One of the following enumeration values: ['all', 'first', 'last', 'none'] Returns ------- Any
Same as `showtickprefix` but for tick suffixes. The 'showticksuffix' property is an enumeration that may be specified as: - One of the following enumeration values: ['all', 'first', 'last', 'none']
def showticksuffix(self): """ Same as `showtickprefix` but for tick suffixes. The 'showticksuffix' property is an enumeration that may be specified as: - One of the following enumeration values: ['all', 'first', 'last', 'none'] Returns ------- Any """ return self["showticksuffix"]
[ "def", "showticksuffix", "(", "self", ")", ":", "return", "self", "[", "\"showticksuffix\"", "]" ]
[ 496, 4 ]
[ 508, 37 ]
python
en
['en', 'error', 'th']
False
ColorBar.thickness
(self)
Sets the thickness of the color bar This measure excludes the size of the padding, ticks and labels. The 'thickness' property is a number and may be specified as: - An int or float in the interval [0, inf] Returns ------- int|float
Sets the thickness of the color bar This measure excludes the size of the padding, ticks and labels. The 'thickness' property is a number and may be specified as: - An int or float in the interval [0, inf]
def thickness(self): """ Sets the thickness of the color bar This measure excludes the size of the padding, ticks and labels. The 'thickness' property is a number and may be specified as: - An int or float in the interval [0, inf] Returns ------- int|float """ return self["thickness"]
[ "def", "thickness", "(", "self", ")", ":", "return", "self", "[", "\"thickness\"", "]" ]
[ 517, 4 ]
[ 529, 32 ]
python
en
['en', 'error', 'th']
False
ColorBar.thicknessmode
(self)
Determines whether this color bar's thickness (i.e. the measure in the constant color direction) is set in units of plot "fraction" or in "pixels". Use `thickness` to set the value. The 'thicknessmode' property is an enumeration that may be specified as: - One of the following enumeration values: ['fraction', 'pixels'] Returns ------- Any
Determines whether this color bar's thickness (i.e. the measure in the constant color direction) is set in units of plot "fraction" or in "pixels". Use `thickness` to set the value. The 'thicknessmode' property is an enumeration that may be specified as: - One of the following enumeration values: ['fraction', 'pixels']
def thicknessmode(self): """ Determines whether this color bar's thickness (i.e. the measure in the constant color direction) is set in units of plot "fraction" or in "pixels". Use `thickness` to set the value. The 'thicknessmode' property is an enumeration that may be specified as: - One of the following enumeration values: ['fraction', 'pixels'] Returns ------- Any """ return self["thicknessmode"]
[ "def", "thicknessmode", "(", "self", ")", ":", "return", "self", "[", "\"thicknessmode\"", "]" ]
[ 538, 4 ]
[ 552, 36 ]
python
en
['en', 'error', 'th']
False
ColorBar.tick0
(self)
Sets the placement of the first tick on this axis. Use with `dtick`. If the axis `type` is "log", then you must take the log of your starting tick (e.g. to set the starting tick to 100, set the `tick0` to 2) except when `dtick`=*L<f>* (see `dtick` for more info). If the axis `type` is "date", it should be a date string, like date data. If the axis `type` is "category", it should be a number, using the scale where each category is assigned a serial number from zero in the order it appears. The 'tick0' property accepts values of any type Returns ------- Any
Sets the placement of the first tick on this axis. Use with `dtick`. If the axis `type` is "log", then you must take the log of your starting tick (e.g. to set the starting tick to 100, set the `tick0` to 2) except when `dtick`=*L<f>* (see `dtick` for more info). If the axis `type` is "date", it should be a date string, like date data. If the axis `type` is "category", it should be a number, using the scale where each category is assigned a serial number from zero in the order it appears. The 'tick0' property accepts values of any type
def tick0(self): """ Sets the placement of the first tick on this axis. Use with `dtick`. If the axis `type` is "log", then you must take the log of your starting tick (e.g. to set the starting tick to 100, set the `tick0` to 2) except when `dtick`=*L<f>* (see `dtick` for more info). If the axis `type` is "date", it should be a date string, like date data. If the axis `type` is "category", it should be a number, using the scale where each category is assigned a serial number from zero in the order it appears. The 'tick0' property accepts values of any type Returns ------- Any """ return self["tick0"]
[ "def", "tick0", "(", "self", ")", ":", "return", "self", "[", "\"tick0\"", "]" ]
[ 561, 4 ]
[ 579, 28 ]
python
en
['en', 'error', 'th']
False
ColorBar.tickangle
(self)
Sets the angle of the tick labels with respect to the horizontal. For example, a `tickangle` of -90 draws the tick labels vertically. The 'tickangle' property is a angle (in degrees) that may be specified as a number between -180 and 180. Numeric values outside this range are converted to the equivalent value (e.g. 270 is converted to -90). Returns ------- int|float
Sets the angle of the tick labels with respect to the horizontal. For example, a `tickangle` of -90 draws the tick labels vertically. The 'tickangle' property is a angle (in degrees) that may be specified as a number between -180 and 180. Numeric values outside this range are converted to the equivalent value (e.g. 270 is converted to -90).
def tickangle(self): """ Sets the angle of the tick labels with respect to the horizontal. For example, a `tickangle` of -90 draws the tick labels vertically. The 'tickangle' property is a angle (in degrees) that may be specified as a number between -180 and 180. Numeric values outside this range are converted to the equivalent value (e.g. 270 is converted to -90). Returns ------- int|float """ return self["tickangle"]
[ "def", "tickangle", "(", "self", ")", ":", "return", "self", "[", "\"tickangle\"", "]" ]
[ 588, 4 ]
[ 603, 32 ]
python
en
['en', 'error', 'th']
False
ColorBar.tickcolor
(self)
Sets the tick color. The 'tickcolor' 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: aliceblue, antiquewhite, aqua, aquamarine, azure, beige, bisque, black, blanchedalmond, blue, blueviolet, brown, burlywood, cadetblue, chartreuse, chocolate, coral, cornflowerblue, cornsilk, crimson, cyan, darkblue, darkcyan, darkgoldenrod, darkgray, darkgrey, darkgreen, darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred, darksalmon, darkseagreen, darkslateblue, darkslategray, darkslategrey, darkturquoise, darkviolet, deeppink, deepskyblue, dimgray, dimgrey, dodgerblue, firebrick, floralwhite, forestgreen, fuchsia, gainsboro, ghostwhite, gold, goldenrod, gray, grey, green, greenyellow, honeydew, hotpink, indianred, indigo, ivory, khaki, lavender, lavenderblush, lawngreen, lemonchiffon, lightblue, lightcoral, lightcyan, lightgoldenrodyellow, lightgray, lightgrey, lightgreen, lightpink, lightsalmon, lightseagreen, lightskyblue, lightslategray, lightslategrey, lightsteelblue, lightyellow, lime, limegreen, linen, magenta, maroon, mediumaquamarine, mediumblue, mediumorchid, mediumpurple, mediumseagreen, mediumslateblue, mediumspringgreen, mediumturquoise, mediumvioletred, midnightblue, mintcream, mistyrose, moccasin, navajowhite, navy, oldlace, olive, olivedrab, orange, orangered, orchid, palegoldenrod, palegreen, paleturquoise, palevioletred, papayawhip, peachpuff, peru, pink, plum, powderblue, purple, red, rosybrown, royalblue, rebeccapurple, saddlebrown, salmon, sandybrown, seagreen, seashell, sienna, silver, skyblue, slateblue, slategray, slategrey, snow, springgreen, steelblue, tan, teal, thistle, tomato, turquoise, violet, wheat, white, whitesmoke, yellow, yellowgreen Returns ------- str
Sets the tick color. The 'tickcolor' 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: aliceblue, antiquewhite, aqua, aquamarine, azure, beige, bisque, black, blanchedalmond, blue, blueviolet, brown, burlywood, cadetblue, chartreuse, chocolate, coral, cornflowerblue, cornsilk, crimson, cyan, darkblue, darkcyan, darkgoldenrod, darkgray, darkgrey, darkgreen, darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred, darksalmon, darkseagreen, darkslateblue, darkslategray, darkslategrey, darkturquoise, darkviolet, deeppink, deepskyblue, dimgray, dimgrey, dodgerblue, firebrick, floralwhite, forestgreen, fuchsia, gainsboro, ghostwhite, gold, goldenrod, gray, grey, green, greenyellow, honeydew, hotpink, indianred, indigo, ivory, khaki, lavender, lavenderblush, lawngreen, lemonchiffon, lightblue, lightcoral, lightcyan, lightgoldenrodyellow, lightgray, lightgrey, lightgreen, lightpink, lightsalmon, lightseagreen, lightskyblue, lightslategray, lightslategrey, lightsteelblue, lightyellow, lime, limegreen, linen, magenta, maroon, mediumaquamarine, mediumblue, mediumorchid, mediumpurple, mediumseagreen, mediumslateblue, mediumspringgreen, mediumturquoise, mediumvioletred, midnightblue, mintcream, mistyrose, moccasin, navajowhite, navy, oldlace, olive, olivedrab, orange, orangered, orchid, palegoldenrod, palegreen, paleturquoise, palevioletred, papayawhip, peachpuff, peru, pink, plum, powderblue, purple, red, rosybrown, royalblue, rebeccapurple, saddlebrown, salmon, sandybrown, seagreen, seashell, sienna, silver, skyblue, slateblue, slategray, slategrey, snow, springgreen, steelblue, tan, teal, thistle, tomato, turquoise, violet, wheat, white, whitesmoke, yellow, yellowgreen
def tickcolor(self): """ Sets the tick color. The 'tickcolor' 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: aliceblue, antiquewhite, aqua, aquamarine, azure, beige, bisque, black, blanchedalmond, blue, blueviolet, brown, burlywood, cadetblue, chartreuse, chocolate, coral, cornflowerblue, cornsilk, crimson, cyan, darkblue, darkcyan, darkgoldenrod, darkgray, darkgrey, darkgreen, darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred, darksalmon, darkseagreen, darkslateblue, darkslategray, darkslategrey, darkturquoise, darkviolet, deeppink, deepskyblue, dimgray, dimgrey, dodgerblue, firebrick, floralwhite, forestgreen, fuchsia, gainsboro, ghostwhite, gold, goldenrod, gray, grey, green, greenyellow, honeydew, hotpink, indianred, indigo, ivory, khaki, lavender, lavenderblush, lawngreen, lemonchiffon, lightblue, lightcoral, lightcyan, lightgoldenrodyellow, lightgray, lightgrey, lightgreen, lightpink, lightsalmon, lightseagreen, lightskyblue, lightslategray, lightslategrey, lightsteelblue, lightyellow, lime, limegreen, linen, magenta, maroon, mediumaquamarine, mediumblue, mediumorchid, mediumpurple, mediumseagreen, mediumslateblue, mediumspringgreen, mediumturquoise, mediumvioletred, midnightblue, mintcream, mistyrose, moccasin, navajowhite, navy, oldlace, olive, olivedrab, orange, orangered, orchid, palegoldenrod, palegreen, paleturquoise, palevioletred, papayawhip, peachpuff, peru, pink, plum, powderblue, purple, red, rosybrown, royalblue, rebeccapurple, saddlebrown, salmon, sandybrown, seagreen, seashell, sienna, silver, skyblue, slateblue, slategray, slategrey, snow, springgreen, steelblue, tan, teal, thistle, tomato, turquoise, violet, wheat, white, whitesmoke, yellow, yellowgreen Returns ------- str """ return self["tickcolor"]
[ "def", "tickcolor", "(", "self", ")", ":", "return", "self", "[", "\"tickcolor\"", "]" ]
[ 612, 4 ]
[ 662, 32 ]
python
en
['en', 'error', 'th']
False
ColorBar.tickfont
(self)
Sets the color bar's tick label font The 'tickfont' property is an instance of Tickfont that may be specified as: - An instance of :class:`plotly.graph_objs.barpolar.marker.colorbar.Tickfont` - A dict of string/value properties that will be passed to the Tickfont constructor Supported dict properties: color family 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 if they aren't available on the system. The Chart Studio Cloud (at https://chart-studio.plotly.com or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include "Arial", "Balto", "Courier New", "Droid Sans",, "Droid Serif", "Droid Sans Mono", "Gravitas One", "Old Standard TT", "Open Sans", "Overpass", "PT Sans Narrow", "Raleway", "Times New Roman". size Returns ------- plotly.graph_objs.barpolar.marker.colorbar.Tickfont
Sets the color bar's tick label font The 'tickfont' property is an instance of Tickfont that may be specified as: - An instance of :class:`plotly.graph_objs.barpolar.marker.colorbar.Tickfont` - A dict of string/value properties that will be passed to the Tickfont constructor Supported dict properties: color family 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 if they aren't available on the system. The Chart Studio Cloud (at https://chart-studio.plotly.com or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include "Arial", "Balto", "Courier New", "Droid Sans",, "Droid Serif", "Droid Sans Mono", "Gravitas One", "Old Standard TT", "Open Sans", "Overpass", "PT Sans Narrow", "Raleway", "Times New Roman". size
def tickfont(self): """ Sets the color bar's tick label font The 'tickfont' property is an instance of Tickfont that may be specified as: - An instance of :class:`plotly.graph_objs.barpolar.marker.colorbar.Tickfont` - A dict of string/value properties that will be passed to the Tickfont constructor Supported dict properties: color family 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 if they aren't available on the system. The Chart Studio Cloud (at https://chart-studio.plotly.com or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include "Arial", "Balto", "Courier New", "Droid Sans",, "Droid Serif", "Droid Sans Mono", "Gravitas One", "Old Standard TT", "Open Sans", "Overpass", "PT Sans Narrow", "Raleway", "Times New Roman". size Returns ------- plotly.graph_objs.barpolar.marker.colorbar.Tickfont """ return self["tickfont"]
[ "def", "tickfont", "(", "self", ")", ":", "return", "self", "[", "\"tickfont\"", "]" ]
[ 671, 4 ]
[ 708, 31 ]
python
en
['en', 'error', 'th']
False
ColorBar.tickformat
(self)
Sets the tick label formatting rule using d3 formatting mini- languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-3.x-api- reference/blob/master/Formatting.md#d3_format And for dates see: https://github.com/d3/d3-3.x-api- reference/blob/master/Time-Formatting.md#format We add one item to d3's date formatter: "%{n}f" for fractional seconds with n digits. For example, *2016-10-13 09:15:23.456* with tickformat "%H~%M~%S.%2f" would display "09~15~23.46" The 'tickformat' property is a string and must be specified as: - A string - A number that will be converted to a string Returns ------- str
Sets the tick label formatting rule using d3 formatting mini- languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-3.x-api- reference/blob/master/Formatting.md#d3_format And for dates see: https://github.com/d3/d3-3.x-api- reference/blob/master/Time-Formatting.md#format We add one item to d3's date formatter: "%{n}f" for fractional seconds with n digits. For example, *2016-10-13 09:15:23.456* with tickformat "%H~%M~%S.%2f" would display "09~15~23.46" The 'tickformat' property is a string and must be specified as: - A string - A number that will be converted to a string
def tickformat(self): """ Sets the tick label formatting rule using d3 formatting mini- languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-3.x-api- reference/blob/master/Formatting.md#d3_format And for dates see: https://github.com/d3/d3-3.x-api- reference/blob/master/Time-Formatting.md#format We add one item to d3's date formatter: "%{n}f" for fractional seconds with n digits. For example, *2016-10-13 09:15:23.456* with tickformat "%H~%M~%S.%2f" would display "09~15~23.46" The 'tickformat' property is a string and must be specified as: - A string - A number that will be converted to a string Returns ------- str """ return self["tickformat"]
[ "def", "tickformat", "(", "self", ")", ":", "return", "self", "[", "\"tickformat\"", "]" ]
[ 717, 4 ]
[ 737, 33 ]
python
en
['en', 'error', 'th']
False
ColorBar.tickformatstops
(self)
The 'tickformatstops' property is a tuple of instances of Tickformatstop that may be specified as: - A list or tuple of instances of plotly.graph_objs.barpolar.marker.colorbar.Tickformatstop - A list or tuple of dicts of string/value properties that will be passed to the Tickformatstop constructor Supported dict properties: dtickrange 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" enabled Determines whether or not this stop is used. If `false`, this stop is ignored even within its `dtickrange`. name 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 (including `visible: false` or `enabled: false` to hide it). Has no effect outside of a template. templateitemname 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 (including `visible: false` or `enabled: false` to hide it). If there is no template or no matching item, this item will be hidden unless you explicitly show it with `visible: true`. value string - dtickformat for described zoom level, the same as "tickformat" Returns ------- tuple[plotly.graph_objs.barpolar.marker.colorbar.Tickformatstop]
The 'tickformatstops' property is a tuple of instances of Tickformatstop that may be specified as: - A list or tuple of instances of plotly.graph_objs.barpolar.marker.colorbar.Tickformatstop - A list or tuple of dicts of string/value properties that will be passed to the Tickformatstop constructor Supported dict properties: dtickrange 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" enabled Determines whether or not this stop is used. If `false`, this stop is ignored even within its `dtickrange`. name 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 (including `visible: false` or `enabled: false` to hide it). Has no effect outside of a template. templateitemname 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 (including `visible: false` or `enabled: false` to hide it). If there is no template or no matching item, this item will be hidden unless you explicitly show it with `visible: true`. value string - dtickformat for described zoom level, the same as "tickformat"
def tickformatstops(self): """ The 'tickformatstops' property is a tuple of instances of Tickformatstop that may be specified as: - A list or tuple of instances of plotly.graph_objs.barpolar.marker.colorbar.Tickformatstop - A list or tuple of dicts of string/value properties that will be passed to the Tickformatstop constructor Supported dict properties: dtickrange 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" enabled Determines whether or not this stop is used. If `false`, this stop is ignored even within its `dtickrange`. name 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 (including `visible: false` or `enabled: false` to hide it). Has no effect outside of a template. templateitemname 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 (including `visible: false` or `enabled: false` to hide it). If there is no template or no matching item, this item will be hidden unless you explicitly show it with `visible: true`. value string - dtickformat for described zoom level, the same as "tickformat" Returns ------- tuple[plotly.graph_objs.barpolar.marker.colorbar.Tickformatstop] """ return self["tickformatstops"]
[ "def", "tickformatstops", "(", "self", ")", ":", "return", "self", "[", "\"tickformatstops\"", "]" ]
[ 746, 4 ]
[ 794, 38 ]
python
en
['en', 'error', 'th']
False
ColorBar.tickformatstopdefaults
(self)
When used in a template (as layout.template.data.barpolar.marke r.colorbar.tickformatstopdefaults), sets the default property values to use for elements of barpolar.marker.colorbar.tickformatstops The 'tickformatstopdefaults' property is an instance of Tickformatstop that may be specified as: - An instance of :class:`plotly.graph_objs.barpolar.marker.colorbar.Tickformatstop` - A dict of string/value properties that will be passed to the Tickformatstop constructor Supported dict properties: Returns ------- plotly.graph_objs.barpolar.marker.colorbar.Tickformatstop
When used in a template (as layout.template.data.barpolar.marke r.colorbar.tickformatstopdefaults), sets the default property values to use for elements of barpolar.marker.colorbar.tickformatstops The 'tickformatstopdefaults' property is an instance of Tickformatstop that may be specified as: - An instance of :class:`plotly.graph_objs.barpolar.marker.colorbar.Tickformatstop` - A dict of string/value properties that will be passed to the Tickformatstop constructor Supported dict properties:
def tickformatstopdefaults(self): """ When used in a template (as layout.template.data.barpolar.marke r.colorbar.tickformatstopdefaults), sets the default property values to use for elements of barpolar.marker.colorbar.tickformatstops The 'tickformatstopdefaults' property is an instance of Tickformatstop that may be specified as: - An instance of :class:`plotly.graph_objs.barpolar.marker.colorbar.Tickformatstop` - A dict of string/value properties that will be passed to the Tickformatstop constructor Supported dict properties: Returns ------- plotly.graph_objs.barpolar.marker.colorbar.Tickformatstop """ return self["tickformatstopdefaults"]
[ "def", "tickformatstopdefaults", "(", "self", ")", ":", "return", "self", "[", "\"tickformatstopdefaults\"", "]" ]
[ 803, 4 ]
[ 822, 45 ]
python
en
['en', 'error', 'th']
False
ColorBar.ticklen
(self)
Sets the tick length (in px). The 'ticklen' property is a number and may be specified as: - An int or float in the interval [0, inf] Returns ------- int|float
Sets the tick length (in px). The 'ticklen' property is a number and may be specified as: - An int or float in the interval [0, inf]
def ticklen(self): """ Sets the tick length (in px). The 'ticklen' property is a number and may be specified as: - An int or float in the interval [0, inf] Returns ------- int|float """ return self["ticklen"]
[ "def", "ticklen", "(", "self", ")", ":", "return", "self", "[", "\"ticklen\"", "]" ]
[ 831, 4 ]
[ 842, 30 ]
python
en
['en', 'error', 'th']
False
ColorBar.tickmode
(self)
Sets the tick mode for this axis. If "auto", the number of ticks is set via `nticks`. If "linear", the placement of the ticks is determined by a starting position `tick0` and a tick step `dtick` ("linear" is the default value if `tick0` and `dtick` are provided). If "array", the placement of the ticks is set via `tickvals` and the tick text is `ticktext`. ("array" is the default value if `tickvals` is provided). The 'tickmode' property is an enumeration that may be specified as: - One of the following enumeration values: ['auto', 'linear', 'array'] Returns ------- Any
Sets the tick mode for this axis. If "auto", the number of ticks is set via `nticks`. If "linear", the placement of the ticks is determined by a starting position `tick0` and a tick step `dtick` ("linear" is the default value if `tick0` and `dtick` are provided). If "array", the placement of the ticks is set via `tickvals` and the tick text is `ticktext`. ("array" is the default value if `tickvals` is provided). The 'tickmode' property is an enumeration that may be specified as: - One of the following enumeration values: ['auto', 'linear', 'array']
def tickmode(self): """ Sets the tick mode for this axis. If "auto", the number of ticks is set via `nticks`. If "linear", the placement of the ticks is determined by a starting position `tick0` and a tick step `dtick` ("linear" is the default value if `tick0` and `dtick` are provided). If "array", the placement of the ticks is set via `tickvals` and the tick text is `ticktext`. ("array" is the default value if `tickvals` is provided). The 'tickmode' property is an enumeration that may be specified as: - One of the following enumeration values: ['auto', 'linear', 'array'] Returns ------- Any """ return self["tickmode"]
[ "def", "tickmode", "(", "self", ")", ":", "return", "self", "[", "\"tickmode\"", "]" ]
[ 851, 4 ]
[ 869, 31 ]
python
en
['en', 'error', 'th']
False
ColorBar.tickprefix
(self)
Sets a tick label prefix. The 'tickprefix' property is a string and must be specified as: - A string - A number that will be converted to a string Returns ------- str
Sets a tick label prefix. The 'tickprefix' property is a string and must be specified as: - A string - A number that will be converted to a string
def tickprefix(self): """ Sets a tick label prefix. The 'tickprefix' property is a string and must be specified as: - A string - A number that will be converted to a string Returns ------- str """ return self["tickprefix"]
[ "def", "tickprefix", "(", "self", ")", ":", "return", "self", "[", "\"tickprefix\"", "]" ]
[ 878, 4 ]
[ 890, 33 ]
python
en
['en', 'error', 'th']
False
ColorBar.ticks
(self)
Determines whether ticks are drawn or not. If "", this axis' ticks are not drawn. If "outside" ("inside"), this axis' are drawn outside (inside) the axis lines. The 'ticks' property is an enumeration that may be specified as: - One of the following enumeration values: ['outside', 'inside', ''] Returns ------- Any
Determines whether ticks are drawn or not. If "", this axis' ticks are not drawn. If "outside" ("inside"), this axis' are drawn outside (inside) the axis lines. The 'ticks' property is an enumeration that may be specified as: - One of the following enumeration values: ['outside', 'inside', '']
def ticks(self): """ Determines whether ticks are drawn or not. If "", this axis' ticks are not drawn. If "outside" ("inside"), this axis' are drawn outside (inside) the axis lines. The 'ticks' property is an enumeration that may be specified as: - One of the following enumeration values: ['outside', 'inside', ''] Returns ------- Any """ return self["ticks"]
[ "def", "ticks", "(", "self", ")", ":", "return", "self", "[", "\"ticks\"", "]" ]
[ 899, 4 ]
[ 913, 28 ]
python
en
['en', 'error', 'th']
False
ColorBar.ticksuffix
(self)
Sets a tick label suffix. The 'ticksuffix' property is a string and must be specified as: - A string - A number that will be converted to a string Returns ------- str
Sets a tick label suffix. The 'ticksuffix' property is a string and must be specified as: - A string - A number that will be converted to a string
def ticksuffix(self): """ Sets a tick label suffix. The 'ticksuffix' property is a string and must be specified as: - A string - A number that will be converted to a string Returns ------- str """ return self["ticksuffix"]
[ "def", "ticksuffix", "(", "self", ")", ":", "return", "self", "[", "\"ticksuffix\"", "]" ]
[ 922, 4 ]
[ 934, 33 ]
python
en
['en', 'error', 'th']
False
ColorBar.ticktext
(self)
Sets the text displayed at the ticks position via `tickvals`. Only has an effect if `tickmode` is set to "array". Used with `tickvals`. The 'ticktext' property is an array that may be specified as a tuple, list, numpy array, or pandas Series Returns ------- numpy.ndarray
Sets the text displayed at the ticks position via `tickvals`. Only has an effect if `tickmode` is set to "array". Used with `tickvals`. The 'ticktext' property is an array that may be specified as a tuple, list, numpy array, or pandas Series
def ticktext(self): """ Sets the text displayed at the ticks position via `tickvals`. Only has an effect if `tickmode` is set to "array". Used with `tickvals`. The 'ticktext' property is an array that may be specified as a tuple, list, numpy array, or pandas Series Returns ------- numpy.ndarray """ return self["ticktext"]
[ "def", "ticktext", "(", "self", ")", ":", "return", "self", "[", "\"ticktext\"", "]" ]
[ 943, 4 ]
[ 956, 31 ]
python
en
['en', 'error', 'th']
False
ColorBar.ticktextsrc
(self)
Sets the source reference on Chart Studio Cloud for ticktext . The 'ticktextsrc' 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 ticktext . The 'ticktextsrc' property must be specified as a string or as a plotly.grid_objs.Column object
def ticktextsrc(self): """ Sets the source reference on Chart Studio Cloud for ticktext . The 'ticktextsrc' property must be specified as a string or as a plotly.grid_objs.Column object Returns ------- str """ return self["ticktextsrc"]
[ "def", "ticktextsrc", "(", "self", ")", ":", "return", "self", "[", "\"ticktextsrc\"", "]" ]
[ 965, 4 ]
[ 976, 34 ]
python
en
['en', 'error', 'th']
False
ColorBar.tickvals
(self)
Sets the values at which ticks on this axis appear. Only has an effect if `tickmode` is set to "array". Used with `ticktext`. The 'tickvals' property is an array that may be specified as a tuple, list, numpy array, or pandas Series Returns ------- numpy.ndarray
Sets the values at which ticks on this axis appear. Only has an effect if `tickmode` is set to "array". Used with `ticktext`. The 'tickvals' property is an array that may be specified as a tuple, list, numpy array, or pandas Series
def tickvals(self): """ Sets the values at which ticks on this axis appear. Only has an effect if `tickmode` is set to "array". Used with `ticktext`. The 'tickvals' property is an array that may be specified as a tuple, list, numpy array, or pandas Series Returns ------- numpy.ndarray """ return self["tickvals"]
[ "def", "tickvals", "(", "self", ")", ":", "return", "self", "[", "\"tickvals\"", "]" ]
[ 985, 4 ]
[ 997, 31 ]
python
en
['en', 'error', 'th']
False
ColorBar.tickvalssrc
(self)
Sets the source reference on Chart Studio Cloud for tickvals . The 'tickvalssrc' 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 tickvals . The 'tickvalssrc' property must be specified as a string or as a plotly.grid_objs.Column object
def tickvalssrc(self): """ Sets the source reference on Chart Studio Cloud for tickvals . The 'tickvalssrc' property must be specified as a string or as a plotly.grid_objs.Column object Returns ------- str """ return self["tickvalssrc"]
[ "def", "tickvalssrc", "(", "self", ")", ":", "return", "self", "[", "\"tickvalssrc\"", "]" ]
[ 1006, 4 ]
[ 1017, 34 ]
python
en
['en', 'error', 'th']
False
ColorBar.tickwidth
(self)
Sets the tick width (in px). The 'tickwidth' property is a number and may be specified as: - An int or float in the interval [0, inf] Returns ------- int|float
Sets the tick width (in px). The 'tickwidth' property is a number and may be specified as: - An int or float in the interval [0, inf]
def tickwidth(self): """ Sets the tick width (in px). The 'tickwidth' property is a number and may be specified as: - An int or float in the interval [0, inf] Returns ------- int|float """ return self["tickwidth"]
[ "def", "tickwidth", "(", "self", ")", ":", "return", "self", "[", "\"tickwidth\"", "]" ]
[ 1026, 4 ]
[ 1037, 32 ]
python
en
['en', 'error', 'th']
False
ColorBar.title
(self)
The 'title' property is an instance of Title that may be specified as: - An instance of :class:`plotly.graph_objs.barpolar.marker.colorbar.Title` - A dict of string/value properties that will be passed to the Title constructor Supported dict properties: font Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute. side Determines the location of color bar's title with respect to the color bar. Note that the title's location used to be set by the now deprecated `titleside` attribute. text Sets the title of the color bar. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated. Returns ------- plotly.graph_objs.barpolar.marker.colorbar.Title
The 'title' property is an instance of Title that may be specified as: - An instance of :class:`plotly.graph_objs.barpolar.marker.colorbar.Title` - A dict of string/value properties that will be passed to the Title constructor Supported dict properties: font Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute. side Determines the location of color bar's title with respect to the color bar. Note that the title's location used to be set by the now deprecated `titleside` attribute. text Sets the title of the color bar. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated.
def title(self): """ The 'title' property is an instance of Title that may be specified as: - An instance of :class:`plotly.graph_objs.barpolar.marker.colorbar.Title` - A dict of string/value properties that will be passed to the Title constructor Supported dict properties: font Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute. side Determines the location of color bar's title with respect to the color bar. Note that the title's location used to be set by the now deprecated `titleside` attribute. text Sets the title of the color bar. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated. Returns ------- plotly.graph_objs.barpolar.marker.colorbar.Title """ return self["title"]
[ "def", "title", "(", "self", ")", ":", "return", "self", "[", "\"title\"", "]" ]
[ 1046, 4 ]
[ 1076, 28 ]
python
en
['en', 'error', 'th']
False
ColorBar.titlefont
(self)
Deprecated: Please use barpolar.marker.colorbar.title.font instead. Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute. The 'font' property is an instance of Font that may be specified as: - An instance of :class:`plotly.graph_objs.barpolar.marker.colorbar.title.Font` - A dict of string/value properties that will be passed to the Font constructor Supported dict properties: color family 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 if they aren't available on the system. The Chart Studio Cloud (at https://chart-studio.plotly.com or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include "Arial", "Balto", "Courier New", "Droid Sans",, "Droid Serif", "Droid Sans Mono", "Gravitas One", "Old Standard TT", "Open Sans", "Overpass", "PT Sans Narrow", "Raleway", "Times New Roman". size Returns -------
Deprecated: Please use barpolar.marker.colorbar.title.font instead. Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute. The 'font' property is an instance of Font that may be specified as: - An instance of :class:`plotly.graph_objs.barpolar.marker.colorbar.title.Font` - A dict of string/value properties that will be passed to the Font constructor Supported dict properties: color family 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 if they aren't available on the system. The Chart Studio Cloud (at https://chart-studio.plotly.com or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include "Arial", "Balto", "Courier New", "Droid Sans",, "Droid Serif", "Droid Sans Mono", "Gravitas One", "Old Standard TT", "Open Sans", "Overpass", "PT Sans Narrow", "Raleway", "Times New Roman". size
def titlefont(self): """ Deprecated: Please use barpolar.marker.colorbar.title.font instead. Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute. The 'font' property is an instance of Font that may be specified as: - An instance of :class:`plotly.graph_objs.barpolar.marker.colorbar.title.Font` - A dict of string/value properties that will be passed to the Font constructor Supported dict properties: color family 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 if they aren't available on the system. The Chart Studio Cloud (at https://chart-studio.plotly.com or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include "Arial", "Balto", "Courier New", "Droid Sans",, "Droid Serif", "Droid Sans Mono", "Gravitas One", "Old Standard TT", "Open Sans", "Overpass", "PT Sans Narrow", "Raleway", "Times New Roman". size Returns ------- """ return self["titlefont"]
[ "def", "titlefont", "(", "self", ")", ":", "return", "self", "[", "\"titlefont\"", "]" ]
[ 1085, 4 ]
[ 1125, 32 ]
python
en
['en', 'error', 'th']
False
ColorBar.titleside
(self)
Deprecated: Please use barpolar.marker.colorbar.title.side instead. Determines the location of color bar's title with respect to the color bar. Note that the title's location used to be set by the now deprecated `titleside` attribute. The 'side' property is an enumeration that may be specified as: - One of the following enumeration values: ['right', 'top', 'bottom'] Returns -------
Deprecated: Please use barpolar.marker.colorbar.title.side instead. Determines the location of color bar's title with respect to the color bar. Note that the title's location used to be set by the now deprecated `titleside` attribute. The 'side' property is an enumeration that may be specified as: - One of the following enumeration values: ['right', 'top', 'bottom']
def titleside(self): """ Deprecated: Please use barpolar.marker.colorbar.title.side instead. Determines the location of color bar's title with respect to the color bar. Note that the title's location used to be set by the now deprecated `titleside` attribute. The 'side' property is an enumeration that may be specified as: - One of the following enumeration values: ['right', 'top', 'bottom'] Returns ------- """ return self["titleside"]
[ "def", "titleside", "(", "self", ")", ":", "return", "self", "[", "\"titleside\"", "]" ]
[ 1134, 4 ]
[ 1149, 32 ]
python
en
['en', 'error', 'th']
False
ColorBar.x
(self)
Sets the x position of the color bar (in plot fraction). The 'x' property is a number and may be specified as: - An int or float in the interval [-2, 3] Returns ------- int|float
Sets the x position of the color bar (in plot fraction). The 'x' property is a number and may be specified as: - An int or float in the interval [-2, 3]
def x(self): """ Sets the x position of the color bar (in plot fraction). The 'x' property is a number and may be specified as: - An int or float in the interval [-2, 3] Returns ------- int|float """ return self["x"]
[ "def", "x", "(", "self", ")", ":", "return", "self", "[", "\"x\"", "]" ]
[ 1158, 4 ]
[ 1169, 24 ]
python
en
['en', 'error', 'th']
False
ColorBar.xanchor
(self)
Sets this color bar's horizontal position anchor. This anchor binds the `x` position to the "left", "center" or "right" of the color bar. The 'xanchor' property is an enumeration that may be specified as: - One of the following enumeration values: ['left', 'center', 'right'] Returns ------- Any
Sets this color bar's horizontal position anchor. This anchor binds the `x` position to the "left", "center" or "right" of the color bar. The 'xanchor' property is an enumeration that may be specified as: - One of the following enumeration values: ['left', 'center', 'right']
def xanchor(self): """ Sets this color bar's horizontal position anchor. This anchor binds the `x` position to the "left", "center" or "right" of the color bar. The 'xanchor' property is an enumeration that may be specified as: - One of the following enumeration values: ['left', 'center', 'right'] Returns ------- Any """ return self["xanchor"]
[ "def", "xanchor", "(", "self", ")", ":", "return", "self", "[", "\"xanchor\"", "]" ]
[ 1178, 4 ]
[ 1192, 30 ]
python
en
['en', 'error', 'th']
False
ColorBar.xpad
(self)
Sets the amount of padding (in px) along the x direction. The 'xpad' property is a number and may be specified as: - An int or float in the interval [0, inf] Returns ------- int|float
Sets the amount of padding (in px) along the x direction. The 'xpad' property is a number and may be specified as: - An int or float in the interval [0, inf]
def xpad(self): """ Sets the amount of padding (in px) along the x direction. The 'xpad' property is a number and may be specified as: - An int or float in the interval [0, inf] Returns ------- int|float """ return self["xpad"]
[ "def", "xpad", "(", "self", ")", ":", "return", "self", "[", "\"xpad\"", "]" ]
[ 1201, 4 ]
[ 1212, 27 ]
python
en
['en', 'error', 'th']
False
ColorBar.y
(self)
Sets the y position of the color bar (in plot fraction). The 'y' property is a number and may be specified as: - An int or float in the interval [-2, 3] Returns ------- int|float
Sets the y position of the color bar (in plot fraction). The 'y' property is a number and may be specified as: - An int or float in the interval [-2, 3]
def y(self): """ Sets the y position of the color bar (in plot fraction). The 'y' property is a number and may be specified as: - An int or float in the interval [-2, 3] Returns ------- int|float """ return self["y"]
[ "def", "y", "(", "self", ")", ":", "return", "self", "[", "\"y\"", "]" ]
[ 1221, 4 ]
[ 1232, 24 ]
python
en
['en', 'error', 'th']
False
ColorBar.yanchor
(self)
Sets this color bar's vertical position anchor This anchor binds the `y` position to the "top", "middle" or "bottom" of the color bar. The 'yanchor' property is an enumeration that may be specified as: - One of the following enumeration values: ['top', 'middle', 'bottom'] Returns ------- Any
Sets this color bar's vertical position anchor This anchor binds the `y` position to the "top", "middle" or "bottom" of the color bar. The 'yanchor' property is an enumeration that may be specified as: - One of the following enumeration values: ['top', 'middle', 'bottom']
def yanchor(self): """ Sets this color bar's vertical position anchor This anchor binds the `y` position to the "top", "middle" or "bottom" of the color bar. The 'yanchor' property is an enumeration that may be specified as: - One of the following enumeration values: ['top', 'middle', 'bottom'] Returns ------- Any """ return self["yanchor"]
[ "def", "yanchor", "(", "self", ")", ":", "return", "self", "[", "\"yanchor\"", "]" ]
[ 1241, 4 ]
[ 1255, 30 ]
python
en
['en', 'error', 'th']
False
ColorBar.ypad
(self)
Sets the amount of padding (in px) along the y direction. The 'ypad' property is a number and may be specified as: - An int or float in the interval [0, inf] Returns ------- int|float
Sets the amount of padding (in px) along the y direction. The 'ypad' property is a number and may be specified as: - An int or float in the interval [0, inf]
def ypad(self): """ Sets the amount of padding (in px) along the y direction. The 'ypad' property is a number and may be specified as: - An int or float in the interval [0, inf] Returns ------- int|float """ return self["ypad"]
[ "def", "ypad", "(", "self", ")", ":", "return", "self", "[", "\"ypad\"", "]" ]
[ 1264, 4 ]
[ 1275, 27 ]
python
en
['en', 'error', 'th']
False
ColorBar.__init__
( self, arg=None, bgcolor=None, bordercolor=None, borderwidth=None, dtick=None, exponentformat=None, len=None, lenmode=None, nticks=None, outlinecolor=None, outlinewidth=None, separatethousands=None, showexponent=None, showticklabels=None, showtickprefix=None, showticksuffix=None, thickness=None, thicknessmode=None, tick0=None, tickangle=None, tickcolor=None, tickfont=None, tickformat=None, tickformatstops=None, tickformatstopdefaults=None, ticklen=None, tickmode=None, tickprefix=None, ticks=None, ticksuffix=None, ticktext=None, ticktextsrc=None, tickvals=None, tickvalssrc=None, tickwidth=None, title=None, titlefont=None, titleside=None, x=None, xanchor=None, xpad=None, y=None, yanchor=None, ypad=None, **kwargs )
Construct a new ColorBar object Parameters ---------- arg dict of properties compatible with this constructor or an instance of :class:`plotly.graph_objs.barpolar.marker.ColorBar` bgcolor Sets the color of padded area. bordercolor Sets the axis line color. borderwidth Sets the width (in px) or the border enclosing this color bar. dtick Sets the step in-between ticks on this axis. Use with `tick0`. Must be a positive number, or special strings available to "log" and "date" axes. If the axis `type` is "log", then ticks are set every 10^(n*dtick) where n is the tick number. For example, to set a tick mark at 1, 10, 100, 1000, ... set dtick to 1. To set tick marks at 1, 100, 10000, ... set dtick to 2. To set tick marks at 1, 5, 25, 125, 625, 3125, ... set dtick to log_10(5), or 0.69897000433. "log" has several special values; "L<f>", where `f` is a positive number, gives ticks linearly spaced in value (but not position). For example `tick0` = 0.1, `dtick` = "L0.5" will put ticks at 0.1, 0.6, 1.1, 1.6 etc. To show powers of 10 plus small digits between, use "D1" (all digits) or "D2" (only 2 and 5). `tick0` is ignored for "D1" and "D2". If the axis `type` is "date", then you must convert the time to milliseconds. For example, to set the interval between ticks to one day, set `dtick` to 86400000.0. "date" also has special values "M<n>" gives ticks spaced by a number of months. `n` must be a positive integer. To set ticks on the 15th of every third month, set `tick0` to "2000-01-15" and `dtick` to "M3". To set ticks every 4 years, set `dtick` to "M48" exponentformat Determines a formatting rule for the tick exponents. For example, consider the number 1,000,000,000. If "none", it appears as 1,000,000,000. If "e", 1e+9. If "E", 1E+9. If "power", 1x10^9 (with 9 in a super script). If "SI", 1G. If "B", 1B. len Sets the length of the color bar This measure excludes the padding of both ends. That is, the color bar length is this length minus the padding on both ends. lenmode Determines whether this color bar's length (i.e. the measure in the color variation direction) is set in units of plot "fraction" or in *pixels. Use `len` to set the value. nticks Specifies the maximum number of ticks for the particular axis. The actual number of ticks will be chosen automatically to be less than or equal to `nticks`. Has an effect only if `tickmode` is set to "auto". outlinecolor Sets the axis line color. outlinewidth Sets the width (in px) of the axis line. separatethousands If "true", even 4-digit integers are separated showexponent If "all", all exponents are shown besides their significands. If "first", only the exponent of the first tick is shown. If "last", only the exponent of the last tick is shown. If "none", no exponents appear. showticklabels Determines whether or not the tick labels are drawn. showtickprefix If "all", all tick labels are displayed with a prefix. If "first", only the first tick is displayed with a prefix. If "last", only the last tick is displayed with a suffix. If "none", tick prefixes are hidden. showticksuffix Same as `showtickprefix` but for tick suffixes. thickness Sets the thickness of the color bar This measure excludes the size of the padding, ticks and labels. thicknessmode Determines whether this color bar's thickness (i.e. the measure in the constant color direction) is set in units of plot "fraction" or in "pixels". Use `thickness` to set the value. tick0 Sets the placement of the first tick on this axis. Use with `dtick`. If the axis `type` is "log", then you must take the log of your starting tick (e.g. to set the starting tick to 100, set the `tick0` to 2) except when `dtick`=*L<f>* (see `dtick` for more info). If the axis `type` is "date", it should be a date string, like date data. If the axis `type` is "category", it should be a number, using the scale where each category is assigned a serial number from zero in the order it appears. tickangle Sets the angle of the tick labels with respect to the horizontal. For example, a `tickangle` of -90 draws the tick labels vertically. tickcolor Sets the tick color. tickfont Sets the color bar's tick label font tickformat Sets the tick label formatting rule using d3 formatting mini-languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-3.x-api- reference/blob/master/Formatting.md#d3_format And for dates see: https://github.com/d3/d3-3.x-api- reference/blob/master/Time-Formatting.md#format We add one item to d3's date formatter: "%{n}f" for fractional seconds with n digits. For example, *2016-10-13 09:15:23.456* with tickformat "%H~%M~%S.%2f" would display "09~15~23.46" tickformatstops A tuple of :class:`plotly.graph_objects.barpolar.marker .colorbar.Tickformatstop` instances or dicts with compatible properties tickformatstopdefaults When used in a template (as layout.template.data.barpol ar.marker.colorbar.tickformatstopdefaults), sets the default property values to use for elements of barpolar.marker.colorbar.tickformatstops ticklen Sets the tick length (in px). tickmode Sets the tick mode for this axis. If "auto", the number of ticks is set via `nticks`. If "linear", the placement of the ticks is determined by a starting position `tick0` and a tick step `dtick` ("linear" is the default value if `tick0` and `dtick` are provided). If "array", the placement of the ticks is set via `tickvals` and the tick text is `ticktext`. ("array" is the default value if `tickvals` is provided). tickprefix Sets a tick label prefix. ticks Determines whether ticks are drawn or not. If "", this axis' ticks are not drawn. If "outside" ("inside"), this axis' are drawn outside (inside) the axis lines. ticksuffix Sets a tick label suffix. ticktext Sets the text displayed at the ticks position via `tickvals`. Only has an effect if `tickmode` is set to "array". Used with `tickvals`. ticktextsrc Sets the source reference on Chart Studio Cloud for ticktext . tickvals Sets the values at which ticks on this axis appear. Only has an effect if `tickmode` is set to "array". Used with `ticktext`. tickvalssrc Sets the source reference on Chart Studio Cloud for tickvals . tickwidth Sets the tick width (in px). title :class:`plotly.graph_objects.barpolar.marker.colorbar.T itle` instance or dict with compatible properties titlefont Deprecated: Please use barpolar.marker.colorbar.title.font instead. Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute. titleside Deprecated: Please use barpolar.marker.colorbar.title.side instead. Determines the location of color bar's title with respect to the color bar. Note that the title's location used to be set by the now deprecated `titleside` attribute. x Sets the x position of the color bar (in plot fraction). xanchor Sets this color bar's horizontal position anchor. This anchor binds the `x` position to the "left", "center" or "right" of the color bar. xpad Sets the amount of padding (in px) along the x direction. y Sets the y position of the color bar (in plot fraction). yanchor Sets this color bar's vertical position anchor This anchor binds the `y` position to the "top", "middle" or "bottom" of the color bar. ypad Sets the amount of padding (in px) along the y direction. Returns ------- ColorBar
Construct a new ColorBar object Parameters ---------- arg dict of properties compatible with this constructor or an instance of :class:`plotly.graph_objs.barpolar.marker.ColorBar` bgcolor Sets the color of padded area. bordercolor Sets the axis line color. borderwidth Sets the width (in px) or the border enclosing this color bar. dtick Sets the step in-between ticks on this axis. Use with `tick0`. Must be a positive number, or special strings available to "log" and "date" axes. If the axis `type` is "log", then ticks are set every 10^(n*dtick) where n is the tick number. For example, to set a tick mark at 1, 10, 100, 1000, ... set dtick to 1. To set tick marks at 1, 100, 10000, ... set dtick to 2. To set tick marks at 1, 5, 25, 125, 625, 3125, ... set dtick to log_10(5), or 0.69897000433. "log" has several special values; "L<f>", where `f` is a positive number, gives ticks linearly spaced in value (but not position). For example `tick0` = 0.1, `dtick` = "L0.5" will put ticks at 0.1, 0.6, 1.1, 1.6 etc. To show powers of 10 plus small digits between, use "D1" (all digits) or "D2" (only 2 and 5). `tick0` is ignored for "D1" and "D2". If the axis `type` is "date", then you must convert the time to milliseconds. For example, to set the interval between ticks to one day, set `dtick` to 86400000.0. "date" also has special values "M<n>" gives ticks spaced by a number of months. `n` must be a positive integer. To set ticks on the 15th of every third month, set `tick0` to "2000-01-15" and `dtick` to "M3". To set ticks every 4 years, set `dtick` to "M48" exponentformat Determines a formatting rule for the tick exponents. For example, consider the number 1,000,000,000. If "none", it appears as 1,000,000,000. If "e", 1e+9. If "E", 1E+9. If "power", 1x10^9 (with 9 in a super script). If "SI", 1G. If "B", 1B. len Sets the length of the color bar This measure excludes the padding of both ends. That is, the color bar length is this length minus the padding on both ends. lenmode Determines whether this color bar's length (i.e. the measure in the color variation direction) is set in units of plot "fraction" or in *pixels. Use `len` to set the value. nticks Specifies the maximum number of ticks for the particular axis. The actual number of ticks will be chosen automatically to be less than or equal to `nticks`. Has an effect only if `tickmode` is set to "auto". outlinecolor Sets the axis line color. outlinewidth Sets the width (in px) of the axis line. separatethousands If "true", even 4-digit integers are separated showexponent If "all", all exponents are shown besides their significands. If "first", only the exponent of the first tick is shown. If "last", only the exponent of the last tick is shown. If "none", no exponents appear. showticklabels Determines whether or not the tick labels are drawn. showtickprefix If "all", all tick labels are displayed with a prefix. If "first", only the first tick is displayed with a prefix. If "last", only the last tick is displayed with a suffix. If "none", tick prefixes are hidden. showticksuffix Same as `showtickprefix` but for tick suffixes. thickness Sets the thickness of the color bar This measure excludes the size of the padding, ticks and labels. thicknessmode Determines whether this color bar's thickness (i.e. the measure in the constant color direction) is set in units of plot "fraction" or in "pixels". Use `thickness` to set the value. tick0 Sets the placement of the first tick on this axis. Use with `dtick`. If the axis `type` is "log", then you must take the log of your starting tick (e.g. to set the starting tick to 100, set the `tick0` to 2) except when `dtick`=*L<f>* (see `dtick` for more info). If the axis `type` is "date", it should be a date string, like date data. If the axis `type` is "category", it should be a number, using the scale where each category is assigned a serial number from zero in the order it appears. tickangle Sets the angle of the tick labels with respect to the horizontal. For example, a `tickangle` of -90 draws the tick labels vertically. tickcolor Sets the tick color. tickfont Sets the color bar's tick label font tickformat Sets the tick label formatting rule using d3 formatting mini-languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-3.x-api- reference/blob/master/Formatting.md#d3_format And for dates see: https://github.com/d3/d3-3.x-api- reference/blob/master/Time-Formatting.md#format We add one item to d3's date formatter: "%{n}f" for fractional seconds with n digits. For example, *2016-10-13 09:15:23.456* with tickformat "%H~%M~%S.%2f" would display "09~15~23.46" tickformatstops A tuple of :class:`plotly.graph_objects.barpolar.marker .colorbar.Tickformatstop` instances or dicts with compatible properties tickformatstopdefaults When used in a template (as layout.template.data.barpol ar.marker.colorbar.tickformatstopdefaults), sets the default property values to use for elements of barpolar.marker.colorbar.tickformatstops ticklen Sets the tick length (in px). tickmode Sets the tick mode for this axis. If "auto", the number of ticks is set via `nticks`. If "linear", the placement of the ticks is determined by a starting position `tick0` and a tick step `dtick` ("linear" is the default value if `tick0` and `dtick` are provided). If "array", the placement of the ticks is set via `tickvals` and the tick text is `ticktext`. ("array" is the default value if `tickvals` is provided). tickprefix Sets a tick label prefix. ticks Determines whether ticks are drawn or not. If "", this axis' ticks are not drawn. If "outside" ("inside"), this axis' are drawn outside (inside) the axis lines. ticksuffix Sets a tick label suffix. ticktext Sets the text displayed at the ticks position via `tickvals`. Only has an effect if `tickmode` is set to "array". Used with `tickvals`. ticktextsrc Sets the source reference on Chart Studio Cloud for ticktext . tickvals Sets the values at which ticks on this axis appear. Only has an effect if `tickmode` is set to "array". Used with `ticktext`. tickvalssrc Sets the source reference on Chart Studio Cloud for tickvals . tickwidth Sets the tick width (in px). title :class:`plotly.graph_objects.barpolar.marker.colorbar.T itle` instance or dict with compatible properties titlefont Deprecated: Please use barpolar.marker.colorbar.title.font instead. Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute. titleside Deprecated: Please use barpolar.marker.colorbar.title.side instead. Determines the location of color bar's title with respect to the color bar. Note that the title's location used to be set by the now deprecated `titleside` attribute. x Sets the x position of the color bar (in plot fraction). xanchor Sets this color bar's horizontal position anchor. This anchor binds the `x` position to the "left", "center" or "right" of the color bar. xpad Sets the amount of padding (in px) along the x direction. y Sets the y position of the color bar (in plot fraction). yanchor Sets this color bar's vertical position anchor This anchor binds the `y` position to the "top", "middle" or "bottom" of the color bar. ypad Sets the amount of padding (in px) along the y direction.
def __init__( self, arg=None, bgcolor=None, bordercolor=None, borderwidth=None, dtick=None, exponentformat=None, len=None, lenmode=None, nticks=None, outlinecolor=None, outlinewidth=None, separatethousands=None, showexponent=None, showticklabels=None, showtickprefix=None, showticksuffix=None, thickness=None, thicknessmode=None, tick0=None, tickangle=None, tickcolor=None, tickfont=None, tickformat=None, tickformatstops=None, tickformatstopdefaults=None, ticklen=None, tickmode=None, tickprefix=None, ticks=None, ticksuffix=None, ticktext=None, ticktextsrc=None, tickvals=None, tickvalssrc=None, tickwidth=None, title=None, titlefont=None, titleside=None, x=None, xanchor=None, xpad=None, y=None, yanchor=None, ypad=None, **kwargs ): """ Construct a new ColorBar object Parameters ---------- arg dict of properties compatible with this constructor or an instance of :class:`plotly.graph_objs.barpolar.marker.ColorBar` bgcolor Sets the color of padded area. bordercolor Sets the axis line color. borderwidth Sets the width (in px) or the border enclosing this color bar. dtick Sets the step in-between ticks on this axis. Use with `tick0`. Must be a positive number, or special strings available to "log" and "date" axes. If the axis `type` is "log", then ticks are set every 10^(n*dtick) where n is the tick number. For example, to set a tick mark at 1, 10, 100, 1000, ... set dtick to 1. To set tick marks at 1, 100, 10000, ... set dtick to 2. To set tick marks at 1, 5, 25, 125, 625, 3125, ... set dtick to log_10(5), or 0.69897000433. "log" has several special values; "L<f>", where `f` is a positive number, gives ticks linearly spaced in value (but not position). For example `tick0` = 0.1, `dtick` = "L0.5" will put ticks at 0.1, 0.6, 1.1, 1.6 etc. To show powers of 10 plus small digits between, use "D1" (all digits) or "D2" (only 2 and 5). `tick0` is ignored for "D1" and "D2". If the axis `type` is "date", then you must convert the time to milliseconds. For example, to set the interval between ticks to one day, set `dtick` to 86400000.0. "date" also has special values "M<n>" gives ticks spaced by a number of months. `n` must be a positive integer. To set ticks on the 15th of every third month, set `tick0` to "2000-01-15" and `dtick` to "M3". To set ticks every 4 years, set `dtick` to "M48" exponentformat Determines a formatting rule for the tick exponents. For example, consider the number 1,000,000,000. If "none", it appears as 1,000,000,000. If "e", 1e+9. If "E", 1E+9. If "power", 1x10^9 (with 9 in a super script). If "SI", 1G. If "B", 1B. len Sets the length of the color bar This measure excludes the padding of both ends. That is, the color bar length is this length minus the padding on both ends. lenmode Determines whether this color bar's length (i.e. the measure in the color variation direction) is set in units of plot "fraction" or in *pixels. Use `len` to set the value. nticks Specifies the maximum number of ticks for the particular axis. The actual number of ticks will be chosen automatically to be less than or equal to `nticks`. Has an effect only if `tickmode` is set to "auto". outlinecolor Sets the axis line color. outlinewidth Sets the width (in px) of the axis line. separatethousands If "true", even 4-digit integers are separated showexponent If "all", all exponents are shown besides their significands. If "first", only the exponent of the first tick is shown. If "last", only the exponent of the last tick is shown. If "none", no exponents appear. showticklabels Determines whether or not the tick labels are drawn. showtickprefix If "all", all tick labels are displayed with a prefix. If "first", only the first tick is displayed with a prefix. If "last", only the last tick is displayed with a suffix. If "none", tick prefixes are hidden. showticksuffix Same as `showtickprefix` but for tick suffixes. thickness Sets the thickness of the color bar This measure excludes the size of the padding, ticks and labels. thicknessmode Determines whether this color bar's thickness (i.e. the measure in the constant color direction) is set in units of plot "fraction" or in "pixels". Use `thickness` to set the value. tick0 Sets the placement of the first tick on this axis. Use with `dtick`. If the axis `type` is "log", then you must take the log of your starting tick (e.g. to set the starting tick to 100, set the `tick0` to 2) except when `dtick`=*L<f>* (see `dtick` for more info). If the axis `type` is "date", it should be a date string, like date data. If the axis `type` is "category", it should be a number, using the scale where each category is assigned a serial number from zero in the order it appears. tickangle Sets the angle of the tick labels with respect to the horizontal. For example, a `tickangle` of -90 draws the tick labels vertically. tickcolor Sets the tick color. tickfont Sets the color bar's tick label font tickformat Sets the tick label formatting rule using d3 formatting mini-languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-3.x-api- reference/blob/master/Formatting.md#d3_format And for dates see: https://github.com/d3/d3-3.x-api- reference/blob/master/Time-Formatting.md#format We add one item to d3's date formatter: "%{n}f" for fractional seconds with n digits. For example, *2016-10-13 09:15:23.456* with tickformat "%H~%M~%S.%2f" would display "09~15~23.46" tickformatstops A tuple of :class:`plotly.graph_objects.barpolar.marker .colorbar.Tickformatstop` instances or dicts with compatible properties tickformatstopdefaults When used in a template (as layout.template.data.barpol ar.marker.colorbar.tickformatstopdefaults), sets the default property values to use for elements of barpolar.marker.colorbar.tickformatstops ticklen Sets the tick length (in px). tickmode Sets the tick mode for this axis. If "auto", the number of ticks is set via `nticks`. If "linear", the placement of the ticks is determined by a starting position `tick0` and a tick step `dtick` ("linear" is the default value if `tick0` and `dtick` are provided). If "array", the placement of the ticks is set via `tickvals` and the tick text is `ticktext`. ("array" is the default value if `tickvals` is provided). tickprefix Sets a tick label prefix. ticks Determines whether ticks are drawn or not. If "", this axis' ticks are not drawn. If "outside" ("inside"), this axis' are drawn outside (inside) the axis lines. ticksuffix Sets a tick label suffix. ticktext Sets the text displayed at the ticks position via `tickvals`. Only has an effect if `tickmode` is set to "array". Used with `tickvals`. ticktextsrc Sets the source reference on Chart Studio Cloud for ticktext . tickvals Sets the values at which ticks on this axis appear. Only has an effect if `tickmode` is set to "array". Used with `ticktext`. tickvalssrc Sets the source reference on Chart Studio Cloud for tickvals . tickwidth Sets the tick width (in px). title :class:`plotly.graph_objects.barpolar.marker.colorbar.T itle` instance or dict with compatible properties titlefont Deprecated: Please use barpolar.marker.colorbar.title.font instead. Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute. titleside Deprecated: Please use barpolar.marker.colorbar.title.side instead. Determines the location of color bar's title with respect to the color bar. Note that the title's location used to be set by the now deprecated `titleside` attribute. x Sets the x position of the color bar (in plot fraction). xanchor Sets this color bar's horizontal position anchor. This anchor binds the `x` position to the "left", "center" or "right" of the color bar. xpad Sets the amount of padding (in px) along the x direction. y Sets the y position of the color bar (in plot fraction). yanchor Sets this color bar's vertical position anchor This anchor binds the `y` position to the "top", "middle" or "bottom" of the color bar. ypad Sets the amount of padding (in px) along the y direction. Returns ------- ColorBar """ super(ColorBar, self).__init__("colorbar") if "_parent" in kwargs: self._parent = kwargs["_parent"] return # Validate arg # ------------ if arg is None: arg = {} elif isinstance(arg, self.__class__): arg = arg.to_plotly_json() elif isinstance(arg, dict): arg = _copy.copy(arg) else: raise ValueError( """\ The first argument to the plotly.graph_objs.barpolar.marker.ColorBar constructor must be a dict or an instance of :class:`plotly.graph_objs.barpolar.marker.ColorBar`""" ) # Handle skip_invalid # ------------------- self._skip_invalid = kwargs.pop("skip_invalid", False) self._validate = kwargs.pop("_validate", True) # Populate data dict with properties # ---------------------------------- _v = arg.pop("bgcolor", None) _v = bgcolor if bgcolor is not None else _v if _v is not None: self["bgcolor"] = _v _v = arg.pop("bordercolor", None) _v = bordercolor if bordercolor is not None else _v if _v is not None: self["bordercolor"] = _v _v = arg.pop("borderwidth", None) _v = borderwidth if borderwidth is not None else _v if _v is not None: self["borderwidth"] = _v _v = arg.pop("dtick", None) _v = dtick if dtick is not None else _v if _v is not None: self["dtick"] = _v _v = arg.pop("exponentformat", None) _v = exponentformat if exponentformat is not None else _v if _v is not None: self["exponentformat"] = _v _v = arg.pop("len", None) _v = len if len is not None else _v if _v is not None: self["len"] = _v _v = arg.pop("lenmode", None) _v = lenmode if lenmode is not None else _v if _v is not None: self["lenmode"] = _v _v = arg.pop("nticks", None) _v = nticks if nticks is not None else _v if _v is not None: self["nticks"] = _v _v = arg.pop("outlinecolor", None) _v = outlinecolor if outlinecolor is not None else _v if _v is not None: self["outlinecolor"] = _v _v = arg.pop("outlinewidth", None) _v = outlinewidth if outlinewidth is not None else _v if _v is not None: self["outlinewidth"] = _v _v = arg.pop("separatethousands", None) _v = separatethousands if separatethousands is not None else _v if _v is not None: self["separatethousands"] = _v _v = arg.pop("showexponent", None) _v = showexponent if showexponent is not None else _v if _v is not None: self["showexponent"] = _v _v = arg.pop("showticklabels", None) _v = showticklabels if showticklabels is not None else _v if _v is not None: self["showticklabels"] = _v _v = arg.pop("showtickprefix", None) _v = showtickprefix if showtickprefix is not None else _v if _v is not None: self["showtickprefix"] = _v _v = arg.pop("showticksuffix", None) _v = showticksuffix if showticksuffix is not None else _v if _v is not None: self["showticksuffix"] = _v _v = arg.pop("thickness", None) _v = thickness if thickness is not None else _v if _v is not None: self["thickness"] = _v _v = arg.pop("thicknessmode", None) _v = thicknessmode if thicknessmode is not None else _v if _v is not None: self["thicknessmode"] = _v _v = arg.pop("tick0", None) _v = tick0 if tick0 is not None else _v if _v is not None: self["tick0"] = _v _v = arg.pop("tickangle", None) _v = tickangle if tickangle is not None else _v if _v is not None: self["tickangle"] = _v _v = arg.pop("tickcolor", None) _v = tickcolor if tickcolor is not None else _v if _v is not None: self["tickcolor"] = _v _v = arg.pop("tickfont", None) _v = tickfont if tickfont is not None else _v if _v is not None: self["tickfont"] = _v _v = arg.pop("tickformat", None) _v = tickformat if tickformat is not None else _v if _v is not None: self["tickformat"] = _v _v = arg.pop("tickformatstops", None) _v = tickformatstops if tickformatstops is not None else _v if _v is not None: self["tickformatstops"] = _v _v = arg.pop("tickformatstopdefaults", None) _v = tickformatstopdefaults if tickformatstopdefaults is not None else _v if _v is not None: self["tickformatstopdefaults"] = _v _v = arg.pop("ticklen", None) _v = ticklen if ticklen is not None else _v if _v is not None: self["ticklen"] = _v _v = arg.pop("tickmode", None) _v = tickmode if tickmode is not None else _v if _v is not None: self["tickmode"] = _v _v = arg.pop("tickprefix", None) _v = tickprefix if tickprefix is not None else _v if _v is not None: self["tickprefix"] = _v _v = arg.pop("ticks", None) _v = ticks if ticks is not None else _v if _v is not None: self["ticks"] = _v _v = arg.pop("ticksuffix", None) _v = ticksuffix if ticksuffix is not None else _v if _v is not None: self["ticksuffix"] = _v _v = arg.pop("ticktext", None) _v = ticktext if ticktext is not None else _v if _v is not None: self["ticktext"] = _v _v = arg.pop("ticktextsrc", None) _v = ticktextsrc if ticktextsrc is not None else _v if _v is not None: self["ticktextsrc"] = _v _v = arg.pop("tickvals", None) _v = tickvals if tickvals is not None else _v if _v is not None: self["tickvals"] = _v _v = arg.pop("tickvalssrc", None) _v = tickvalssrc if tickvalssrc is not None else _v if _v is not None: self["tickvalssrc"] = _v _v = arg.pop("tickwidth", None) _v = tickwidth if tickwidth is not None else _v if _v is not None: self["tickwidth"] = _v _v = arg.pop("title", None) _v = title if title is not None else _v if _v is not None: self["title"] = _v _v = arg.pop("titlefont", None) _v = titlefont if titlefont is not None else _v if _v is not None: self["titlefont"] = _v _v = arg.pop("titleside", None) _v = titleside if titleside is not None else _v if _v is not None: self["titleside"] = _v _v = arg.pop("x", None) _v = x if x is not None else _v if _v is not None: self["x"] = _v _v = arg.pop("xanchor", None) _v = xanchor if xanchor is not None else _v if _v is not None: self["xanchor"] = _v _v = arg.pop("xpad", None) _v = xpad if xpad is not None else _v if _v is not None: self["xpad"] = _v _v = arg.pop("y", None) _v = y if y is not None else _v if _v is not None: self["y"] = _v _v = arg.pop("yanchor", None) _v = yanchor if yanchor is not None else _v if _v is not None: self["yanchor"] = _v _v = arg.pop("ypad", None) _v = ypad if ypad is not None else _v if _v is not None: self["ypad"] = _v # Process unknown kwargs # ---------------------- self._process_kwargs(**dict(arg, **kwargs)) # Reset skip_invalid # ------------------ self._skip_invalid = False
[ "def", "__init__", "(", "self", ",", "arg", "=", "None", ",", "bgcolor", "=", "None", ",", "bordercolor", "=", "None", ",", "borderwidth", "=", "None", ",", "dtick", "=", "None", ",", "exponentformat", "=", "None", ",", "len", "=", "None", ",", "lenmode", "=", "None", ",", "nticks", "=", "None", ",", "outlinecolor", "=", "None", ",", "outlinewidth", "=", "None", ",", "separatethousands", "=", "None", ",", "showexponent", "=", "None", ",", "showticklabels", "=", "None", ",", "showtickprefix", "=", "None", ",", "showticksuffix", "=", "None", ",", "thickness", "=", "None", ",", "thicknessmode", "=", "None", ",", "tick0", "=", "None", ",", "tickangle", "=", "None", ",", "tickcolor", "=", "None", ",", "tickfont", "=", "None", ",", "tickformat", "=", "None", ",", "tickformatstops", "=", "None", ",", "tickformatstopdefaults", "=", "None", ",", "ticklen", "=", "None", ",", "tickmode", "=", "None", ",", "tickprefix", "=", "None", ",", "ticks", "=", "None", ",", "ticksuffix", "=", "None", ",", "ticktext", "=", "None", ",", "ticktextsrc", "=", "None", ",", "tickvals", "=", "None", ",", "tickvalssrc", "=", "None", ",", "tickwidth", "=", "None", ",", "title", "=", "None", ",", "titlefont", "=", "None", ",", "titleside", "=", "None", ",", "x", "=", "None", ",", "xanchor", "=", "None", ",", "xpad", "=", "None", ",", "y", "=", "None", ",", "yanchor", "=", "None", ",", "ypad", "=", "None", ",", "*", "*", "kwargs", ")", ":", "super", "(", "ColorBar", ",", "self", ")", ".", "__init__", "(", "\"colorbar\"", ")", "if", "\"_parent\"", "in", "kwargs", ":", "self", ".", "_parent", "=", "kwargs", "[", "\"_parent\"", "]", "return", "# Validate arg", "# ------------", "if", "arg", "is", "None", ":", "arg", "=", "{", "}", "elif", "isinstance", "(", "arg", ",", "self", ".", "__class__", ")", ":", "arg", "=", "arg", ".", "to_plotly_json", "(", ")", "elif", "isinstance", "(", "arg", ",", "dict", ")", ":", "arg", "=", "_copy", ".", "copy", "(", "arg", ")", "else", ":", "raise", "ValueError", "(", "\"\"\"\\\nThe first argument to the plotly.graph_objs.barpolar.marker.ColorBar \nconstructor must be a dict or \nan instance of :class:`plotly.graph_objs.barpolar.marker.ColorBar`\"\"\"", ")", "# Handle skip_invalid", "# -------------------", "self", ".", "_skip_invalid", "=", "kwargs", ".", "pop", "(", "\"skip_invalid\"", ",", "False", ")", "self", ".", "_validate", "=", "kwargs", ".", "pop", "(", "\"_validate\"", ",", "True", ")", "# Populate data dict with properties", "# ----------------------------------", "_v", "=", "arg", ".", "pop", "(", "\"bgcolor\"", ",", "None", ")", "_v", "=", "bgcolor", "if", "bgcolor", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"bgcolor\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"bordercolor\"", ",", "None", ")", "_v", "=", "bordercolor", "if", "bordercolor", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"bordercolor\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"borderwidth\"", ",", "None", ")", "_v", "=", "borderwidth", "if", "borderwidth", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"borderwidth\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"dtick\"", ",", "None", ")", "_v", "=", "dtick", "if", "dtick", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"dtick\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"exponentformat\"", ",", "None", ")", "_v", "=", "exponentformat", "if", "exponentformat", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"exponentformat\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"len\"", ",", "None", ")", "_v", "=", "len", "if", "len", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"len\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"lenmode\"", ",", "None", ")", "_v", "=", "lenmode", "if", "lenmode", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"lenmode\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"nticks\"", ",", "None", ")", "_v", "=", "nticks", "if", "nticks", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"nticks\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"outlinecolor\"", ",", "None", ")", "_v", "=", "outlinecolor", "if", "outlinecolor", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"outlinecolor\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"outlinewidth\"", ",", "None", ")", "_v", "=", "outlinewidth", "if", "outlinewidth", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"outlinewidth\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"separatethousands\"", ",", "None", ")", "_v", "=", "separatethousands", "if", "separatethousands", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"separatethousands\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"showexponent\"", ",", "None", ")", "_v", "=", "showexponent", "if", "showexponent", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"showexponent\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"showticklabels\"", ",", "None", ")", "_v", "=", "showticklabels", "if", "showticklabels", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"showticklabels\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"showtickprefix\"", ",", "None", ")", "_v", "=", "showtickprefix", "if", "showtickprefix", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"showtickprefix\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"showticksuffix\"", ",", "None", ")", "_v", "=", "showticksuffix", "if", "showticksuffix", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"showticksuffix\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"thickness\"", ",", "None", ")", "_v", "=", "thickness", "if", "thickness", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"thickness\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"thicknessmode\"", ",", "None", ")", "_v", "=", "thicknessmode", "if", "thicknessmode", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"thicknessmode\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"tick0\"", ",", "None", ")", "_v", "=", "tick0", "if", "tick0", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"tick0\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"tickangle\"", ",", "None", ")", "_v", "=", "tickangle", "if", "tickangle", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"tickangle\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"tickcolor\"", ",", "None", ")", "_v", "=", "tickcolor", "if", "tickcolor", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"tickcolor\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"tickfont\"", ",", "None", ")", "_v", "=", "tickfont", "if", "tickfont", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"tickfont\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"tickformat\"", ",", "None", ")", "_v", "=", "tickformat", "if", "tickformat", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"tickformat\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"tickformatstops\"", ",", "None", ")", "_v", "=", "tickformatstops", "if", "tickformatstops", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"tickformatstops\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"tickformatstopdefaults\"", ",", "None", ")", "_v", "=", "tickformatstopdefaults", "if", "tickformatstopdefaults", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"tickformatstopdefaults\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"ticklen\"", ",", "None", ")", "_v", "=", "ticklen", "if", "ticklen", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"ticklen\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"tickmode\"", ",", "None", ")", "_v", "=", "tickmode", "if", "tickmode", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"tickmode\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"tickprefix\"", ",", "None", ")", "_v", "=", "tickprefix", "if", "tickprefix", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"tickprefix\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"ticks\"", ",", "None", ")", "_v", "=", "ticks", "if", "ticks", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"ticks\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"ticksuffix\"", ",", "None", ")", "_v", "=", "ticksuffix", "if", "ticksuffix", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"ticksuffix\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"ticktext\"", ",", "None", ")", "_v", "=", "ticktext", "if", "ticktext", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"ticktext\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"ticktextsrc\"", ",", "None", ")", "_v", "=", "ticktextsrc", "if", "ticktextsrc", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"ticktextsrc\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"tickvals\"", ",", "None", ")", "_v", "=", "tickvals", "if", "tickvals", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"tickvals\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"tickvalssrc\"", ",", "None", ")", "_v", "=", "tickvalssrc", "if", "tickvalssrc", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"tickvalssrc\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"tickwidth\"", ",", "None", ")", "_v", "=", "tickwidth", "if", "tickwidth", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"tickwidth\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"title\"", ",", "None", ")", "_v", "=", "title", "if", "title", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"title\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"titlefont\"", ",", "None", ")", "_v", "=", "titlefont", "if", "titlefont", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"titlefont\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"titleside\"", ",", "None", ")", "_v", "=", "titleside", "if", "titleside", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"titleside\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"x\"", ",", "None", ")", "_v", "=", "x", "if", "x", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"x\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"xanchor\"", ",", "None", ")", "_v", "=", "xanchor", "if", "xanchor", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"xanchor\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"xpad\"", ",", "None", ")", "_v", "=", "xpad", "if", "xpad", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"xpad\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"y\"", ",", "None", ")", "_v", "=", "y", "if", "y", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"y\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"yanchor\"", ",", "None", ")", "_v", "=", "yanchor", "if", "yanchor", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"yanchor\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"ypad\"", ",", "None", ")", "_v", "=", "ypad", "if", "ypad", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"ypad\"", "]", "=", "_v", "# Process unknown kwargs", "# ----------------------", "self", ".", "_process_kwargs", "(", "*", "*", "dict", "(", "arg", ",", "*", "*", "kwargs", ")", ")", "# Reset skip_invalid", "# ------------------", "self", ".", "_skip_invalid", "=", "False" ]
[ 1482, 4 ]
[ 1941, 34 ]
python
en
['en', 'error', 'th']
False
_get_prototype
(inprot, protparents, uninherited=None, _workprot=None)
Recursively traverse a prototype dictionary, including multiple inheritance. Use validate_prototype before this, we don't check for infinite recursion here. Args: inprot (dict): Prototype dict (the individual prototype, with no inheritance included). protparents (dict): Available protparents, keyed by prototype_key. uninherited (dict): Parts of prototype to not inherit. _workprot (dict, optional): Work dict for the recursive algorithm.
Recursively traverse a prototype dictionary, including multiple inheritance. Use validate_prototype before this, we don't check for infinite recursion here.
def _get_prototype(inprot, protparents, uninherited=None, _workprot=None): """ Recursively traverse a prototype dictionary, including multiple inheritance. Use validate_prototype before this, we don't check for infinite recursion here. Args: inprot (dict): Prototype dict (the individual prototype, with no inheritance included). protparents (dict): Available protparents, keyed by prototype_key. uninherited (dict): Parts of prototype to not inherit. _workprot (dict, optional): Work dict for the recursive algorithm. """ _workprot = {} if _workprot is None else _workprot if "prototype_parent" in inprot: # move backwards through the inheritance for prototype in make_iter(inprot["prototype_parent"]): # Build the prot dictionary in reverse order, overloading new_prot = _get_prototype(protparents.get(prototype.lower(), {}), protparents, _workprot=_workprot) _workprot.update(new_prot) # the inprot represents a higher level (a child prot), which should override parents _workprot.update(inprot) if uninherited: # put back the parts that should not be inherited _workprot.update(uninherited) _workprot.pop("prototype_parent", None) # we don't need this for spawning return _workprot
[ "def", "_get_prototype", "(", "inprot", ",", "protparents", ",", "uninherited", "=", "None", ",", "_workprot", "=", "None", ")", ":", "_workprot", "=", "{", "}", "if", "_workprot", "is", "None", "else", "_workprot", "if", "\"prototype_parent\"", "in", "inprot", ":", "# move backwards through the inheritance", "for", "prototype", "in", "make_iter", "(", "inprot", "[", "\"prototype_parent\"", "]", ")", ":", "# Build the prot dictionary in reverse order, overloading", "new_prot", "=", "_get_prototype", "(", "protparents", ".", "get", "(", "prototype", ".", "lower", "(", ")", ",", "{", "}", ")", ",", "protparents", ",", "_workprot", "=", "_workprot", ")", "_workprot", ".", "update", "(", "new_prot", ")", "# the inprot represents a higher level (a child prot), which should override parents", "_workprot", ".", "update", "(", "inprot", ")", "if", "uninherited", ":", "# put back the parts that should not be inherited", "_workprot", ".", "update", "(", "uninherited", ")", "_workprot", ".", "pop", "(", "\"prototype_parent\"", ",", "None", ")", "# we don't need this for spawning", "return", "_workprot" ]
[ 155, 0 ]
[ 182, 20 ]
python
en
['en', 'error', 'th']
False
flatten_prototype
(prototype, validate=False)
Produce a 'flattened' prototype, where all prototype parents in the inheritance tree have been merged into a final prototype. Args: prototype (dict): Prototype to flatten. Its `prototype_parent` field will be parsed. validate (bool, optional): Validate for valid keys etc. Returns: flattened (dict): The final, flattened prototype.
Produce a 'flattened' prototype, where all prototype parents in the inheritance tree have been merged into a final prototype.
def flatten_prototype(prototype, validate=False): """ Produce a 'flattened' prototype, where all prototype parents in the inheritance tree have been merged into a final prototype. Args: prototype (dict): Prototype to flatten. Its `prototype_parent` field will be parsed. validate (bool, optional): Validate for valid keys etc. Returns: flattened (dict): The final, flattened prototype. """ if prototype: prototype = protlib.homogenize_prototype(prototype) protparents = {prot['prototype_key'].lower(): prot for prot in protlib.search_prototype()} protlib.validate_prototype(prototype, None, protparents, is_prototype_base=validate, strict=validate) return _get_prototype(prototype, protparents, uninherited={"prototype_key": prototype.get("prototype_key")}) return {}
[ "def", "flatten_prototype", "(", "prototype", ",", "validate", "=", "False", ")", ":", "if", "prototype", ":", "prototype", "=", "protlib", ".", "homogenize_prototype", "(", "prototype", ")", "protparents", "=", "{", "prot", "[", "'prototype_key'", "]", ".", "lower", "(", ")", ":", "prot", "for", "prot", "in", "protlib", ".", "search_prototype", "(", ")", "}", "protlib", ".", "validate_prototype", "(", "prototype", ",", "None", ",", "protparents", ",", "is_prototype_base", "=", "validate", ",", "strict", "=", "validate", ")", "return", "_get_prototype", "(", "prototype", ",", "protparents", ",", "uninherited", "=", "{", "\"prototype_key\"", ":", "prototype", ".", "get", "(", "\"prototype_key\"", ")", "}", ")", "return", "{", "}" ]
[ 185, 0 ]
[ 206, 13 ]
python
en
['en', 'error', 'th']
False
prototype_from_object
(obj)
Guess a minimal prototype from an existing object. Args: obj (Object): An object to analyze. Returns: prototype (dict): A prototype estimating the current state of the object.
Guess a minimal prototype from an existing object.
def prototype_from_object(obj): """ Guess a minimal prototype from an existing object. Args: obj (Object): An object to analyze. Returns: prototype (dict): A prototype estimating the current state of the object. """ # first, check if this object already has a prototype prot = obj.tags.get(category=_PROTOTYPE_TAG_CATEGORY, return_list=True) if prot: prot = protlib.search_prototype(prot[0]) if not prot or len(prot) > 1: # no unambiguous prototype found - build new prototype prot = {} prot['prototype_key'] = "From-Object-{}-{}".format( obj.key, hashlib.md5(str(time.time())).hexdigest()[:7]) prot['prototype_desc'] = "Built from {}".format(str(obj)) prot['prototype_locks'] = "spawn:all();edit:all()" prot['prototype_tags'] = [] else: prot = prot[0] prot['key'] = obj.db_key or hashlib.md5(str(time.time())).hexdigest()[:6] prot['typeclass'] = obj.db_typeclass_path location = obj.db_location if location: prot['location'] = location.dbref home = obj.db_home if home: prot['home'] = home.dbref destination = obj.db_destination if destination: prot['destination'] = destination.dbref locks = obj.locks.all() if locks: prot['locks'] = ";".join(locks) perms = obj.permissions.get(return_list=True) if perms: prot['permissions'] = make_iter(perms) aliases = obj.aliases.get(return_list=True) if aliases: prot['aliases'] = aliases tags = [(tag.db_key, tag.db_category, tag.db_data) for tag in obj.tags.all(return_objs=True)] if tags: prot['tags'] = tags attrs = [(attr.key, attr.value, attr.category, ';'.join(attr.locks.all())) for attr in obj.attributes.all()] if attrs: prot['attrs'] = attrs return prot
[ "def", "prototype_from_object", "(", "obj", ")", ":", "# first, check if this object already has a prototype", "prot", "=", "obj", ".", "tags", ".", "get", "(", "category", "=", "_PROTOTYPE_TAG_CATEGORY", ",", "return_list", "=", "True", ")", "if", "prot", ":", "prot", "=", "protlib", ".", "search_prototype", "(", "prot", "[", "0", "]", ")", "if", "not", "prot", "or", "len", "(", "prot", ")", ">", "1", ":", "# no unambiguous prototype found - build new prototype", "prot", "=", "{", "}", "prot", "[", "'prototype_key'", "]", "=", "\"From-Object-{}-{}\"", ".", "format", "(", "obj", ".", "key", ",", "hashlib", ".", "md5", "(", "str", "(", "time", ".", "time", "(", ")", ")", ")", ".", "hexdigest", "(", ")", "[", ":", "7", "]", ")", "prot", "[", "'prototype_desc'", "]", "=", "\"Built from {}\"", ".", "format", "(", "str", "(", "obj", ")", ")", "prot", "[", "'prototype_locks'", "]", "=", "\"spawn:all();edit:all()\"", "prot", "[", "'prototype_tags'", "]", "=", "[", "]", "else", ":", "prot", "=", "prot", "[", "0", "]", "prot", "[", "'key'", "]", "=", "obj", ".", "db_key", "or", "hashlib", ".", "md5", "(", "str", "(", "time", ".", "time", "(", ")", ")", ")", ".", "hexdigest", "(", ")", "[", ":", "6", "]", "prot", "[", "'typeclass'", "]", "=", "obj", ".", "db_typeclass_path", "location", "=", "obj", ".", "db_location", "if", "location", ":", "prot", "[", "'location'", "]", "=", "location", ".", "dbref", "home", "=", "obj", ".", "db_home", "if", "home", ":", "prot", "[", "'home'", "]", "=", "home", ".", "dbref", "destination", "=", "obj", ".", "db_destination", "if", "destination", ":", "prot", "[", "'destination'", "]", "=", "destination", ".", "dbref", "locks", "=", "obj", ".", "locks", ".", "all", "(", ")", "if", "locks", ":", "prot", "[", "'locks'", "]", "=", "\";\"", ".", "join", "(", "locks", ")", "perms", "=", "obj", ".", "permissions", ".", "get", "(", "return_list", "=", "True", ")", "if", "perms", ":", "prot", "[", "'permissions'", "]", "=", "make_iter", "(", "perms", ")", "aliases", "=", "obj", ".", "aliases", ".", "get", "(", "return_list", "=", "True", ")", "if", "aliases", ":", "prot", "[", "'aliases'", "]", "=", "aliases", "tags", "=", "[", "(", "tag", ".", "db_key", ",", "tag", ".", "db_category", ",", "tag", ".", "db_data", ")", "for", "tag", "in", "obj", ".", "tags", ".", "all", "(", "return_objs", "=", "True", ")", "]", "if", "tags", ":", "prot", "[", "'tags'", "]", "=", "tags", "attrs", "=", "[", "(", "attr", ".", "key", ",", "attr", ".", "value", ",", "attr", ".", "category", ",", "';'", ".", "join", "(", "attr", ".", "locks", ".", "all", "(", ")", ")", ")", "for", "attr", "in", "obj", ".", "attributes", ".", "all", "(", ")", "]", "if", "attrs", ":", "prot", "[", "'attrs'", "]", "=", "attrs", "return", "prot" ]
[ 211, 0 ]
[ 269, 15 ]
python
en
['en', 'error', 'th']
False
prototype_diff
(prototype1, prototype2, maxdepth=2)
A 'detailed' diff specifies differences down to individual sub-sectiions of the prototype, like individual attributes, permissions etc. It is used by the menu to allow a user to customize what should be kept. Args: prototype1 (dict): Original prototype. prototype2 (dict): Comparison prototype. maxdepth (int, optional): The maximum depth into the diff we go before treating the elements of iterables as individual entities to compare. This is important since a single attr/tag (for example) are represented by a tuple. Returns: diff (dict): A structure detailing how to convert prototype1 to prototype2. All nested structures are dicts with keys matching either the prototype's matching key or the first element in the tuple describing the prototype value (so for a tag tuple `(tagname, category)` the second-level key in the diff would be tagname). The the bottom level of the diff consist of tuples `(old, new, instruction)`, where instruction can be one of "REMOVE", "ADD", "UPDATE" or "KEEP".
A 'detailed' diff specifies differences down to individual sub-sectiions of the prototype, like individual attributes, permissions etc. It is used by the menu to allow a user to customize what should be kept.
def prototype_diff(prototype1, prototype2, maxdepth=2): """ A 'detailed' diff specifies differences down to individual sub-sectiions of the prototype, like individual attributes, permissions etc. It is used by the menu to allow a user to customize what should be kept. Args: prototype1 (dict): Original prototype. prototype2 (dict): Comparison prototype. maxdepth (int, optional): The maximum depth into the diff we go before treating the elements of iterables as individual entities to compare. This is important since a single attr/tag (for example) are represented by a tuple. Returns: diff (dict): A structure detailing how to convert prototype1 to prototype2. All nested structures are dicts with keys matching either the prototype's matching key or the first element in the tuple describing the prototype value (so for a tag tuple `(tagname, category)` the second-level key in the diff would be tagname). The the bottom level of the diff consist of tuples `(old, new, instruction)`, where instruction can be one of "REMOVE", "ADD", "UPDATE" or "KEEP". """ def _recursive_diff(old, new, depth=0): old_type = type(old) new_type = type(new) if old_type != new_type: if old and not new: if depth < maxdepth and old_type == dict: return {key: (part, None, "REMOVE") for key, part in old.items()} elif depth < maxdepth and is_iter(old): return {part[0] if is_iter(part) else part: (part, None, "REMOVE") for part in old} return (old, new, "REMOVE") elif not old and new: if depth < maxdepth and new_type == dict: return {key: (None, part, "ADD") for key, part in new.items()} elif depth < maxdepth and is_iter(new): return {part[0] if is_iter(part) else part: (None, part, "ADD") for part in new} return (old, new, "ADD") else: # this condition should not occur in a standard diff return (old, new, "UPDATE") elif depth < maxdepth and new_type == dict: all_keys = set(old.keys() + new.keys()) return {key: _recursive_diff(old.get(key), new.get(key), depth=depth + 1) for key in all_keys} elif depth < maxdepth and is_iter(new): old_map = {part[0] if is_iter(part) else part: part for part in old} new_map = {part[0] if is_iter(part) else part: part for part in new} all_keys = set(old_map.keys() + new_map.keys()) return {key: _recursive_diff(old_map.get(key), new_map.get(key), depth=depth + 1) for key in all_keys} elif old != new: return (old, new, "UPDATE") else: return (old, new, "KEEP") diff = _recursive_diff(prototype1, prototype2) return diff
[ "def", "prototype_diff", "(", "prototype1", ",", "prototype2", ",", "maxdepth", "=", "2", ")", ":", "def", "_recursive_diff", "(", "old", ",", "new", ",", "depth", "=", "0", ")", ":", "old_type", "=", "type", "(", "old", ")", "new_type", "=", "type", "(", "new", ")", "if", "old_type", "!=", "new_type", ":", "if", "old", "and", "not", "new", ":", "if", "depth", "<", "maxdepth", "and", "old_type", "==", "dict", ":", "return", "{", "key", ":", "(", "part", ",", "None", ",", "\"REMOVE\"", ")", "for", "key", ",", "part", "in", "old", ".", "items", "(", ")", "}", "elif", "depth", "<", "maxdepth", "and", "is_iter", "(", "old", ")", ":", "return", "{", "part", "[", "0", "]", "if", "is_iter", "(", "part", ")", "else", "part", ":", "(", "part", ",", "None", ",", "\"REMOVE\"", ")", "for", "part", "in", "old", "}", "return", "(", "old", ",", "new", ",", "\"REMOVE\"", ")", "elif", "not", "old", "and", "new", ":", "if", "depth", "<", "maxdepth", "and", "new_type", "==", "dict", ":", "return", "{", "key", ":", "(", "None", ",", "part", ",", "\"ADD\"", ")", "for", "key", ",", "part", "in", "new", ".", "items", "(", ")", "}", "elif", "depth", "<", "maxdepth", "and", "is_iter", "(", "new", ")", ":", "return", "{", "part", "[", "0", "]", "if", "is_iter", "(", "part", ")", "else", "part", ":", "(", "None", ",", "part", ",", "\"ADD\"", ")", "for", "part", "in", "new", "}", "return", "(", "old", ",", "new", ",", "\"ADD\"", ")", "else", ":", "# this condition should not occur in a standard diff", "return", "(", "old", ",", "new", ",", "\"UPDATE\"", ")", "elif", "depth", "<", "maxdepth", "and", "new_type", "==", "dict", ":", "all_keys", "=", "set", "(", "old", ".", "keys", "(", ")", "+", "new", ".", "keys", "(", ")", ")", "return", "{", "key", ":", "_recursive_diff", "(", "old", ".", "get", "(", "key", ")", ",", "new", ".", "get", "(", "key", ")", ",", "depth", "=", "depth", "+", "1", ")", "for", "key", "in", "all_keys", "}", "elif", "depth", "<", "maxdepth", "and", "is_iter", "(", "new", ")", ":", "old_map", "=", "{", "part", "[", "0", "]", "if", "is_iter", "(", "part", ")", "else", "part", ":", "part", "for", "part", "in", "old", "}", "new_map", "=", "{", "part", "[", "0", "]", "if", "is_iter", "(", "part", ")", "else", "part", ":", "part", "for", "part", "in", "new", "}", "all_keys", "=", "set", "(", "old_map", ".", "keys", "(", ")", "+", "new_map", ".", "keys", "(", ")", ")", "return", "{", "key", ":", "_recursive_diff", "(", "old_map", ".", "get", "(", "key", ")", ",", "new_map", ".", "get", "(", "key", ")", ",", "depth", "=", "depth", "+", "1", ")", "for", "key", "in", "all_keys", "}", "elif", "old", "!=", "new", ":", "return", "(", "old", ",", "new", ",", "\"UPDATE\"", ")", "else", ":", "return", "(", "old", ",", "new", ",", "\"KEEP\"", ")", "diff", "=", "_recursive_diff", "(", "prototype1", ",", "prototype2", ")", "return", "diff" ]
[ 272, 0 ]
[ 333, 15 ]
python
en
['en', 'error', 'th']
False
flatten_diff
(diff)
For spawning, a 'detailed' diff is not necessary, rather we just want instructions on how to handle each root key. Args: diff (dict): Diff produced by `prototype_diff` and possibly modified by the user. Note that also a pre-flattened diff will come out unchanged by this function. Returns: flattened_diff (dict): A flat structure detailing how to operate on each root component of the prototype. Notes: The flattened diff has the following possible instructions: UPDATE, REPLACE, REMOVE Many of the detailed diff's values can hold nested structures with their own individual instructions. A detailed diff can have the following instructions: REMOVE, ADD, UPDATE, KEEP Here's how they are translated: - All REMOVE -> REMOVE - All ADD|UPDATE -> UPDATE - All KEEP -> KEEP - Mix KEEP, UPDATE, ADD -> UPDATE - Mix REMOVE, KEEP, UPDATE, ADD -> REPLACE
For spawning, a 'detailed' diff is not necessary, rather we just want instructions on how to handle each root key.
def flatten_diff(diff): """ For spawning, a 'detailed' diff is not necessary, rather we just want instructions on how to handle each root key. Args: diff (dict): Diff produced by `prototype_diff` and possibly modified by the user. Note that also a pre-flattened diff will come out unchanged by this function. Returns: flattened_diff (dict): A flat structure detailing how to operate on each root component of the prototype. Notes: The flattened diff has the following possible instructions: UPDATE, REPLACE, REMOVE Many of the detailed diff's values can hold nested structures with their own individual instructions. A detailed diff can have the following instructions: REMOVE, ADD, UPDATE, KEEP Here's how they are translated: - All REMOVE -> REMOVE - All ADD|UPDATE -> UPDATE - All KEEP -> KEEP - Mix KEEP, UPDATE, ADD -> UPDATE - Mix REMOVE, KEEP, UPDATE, ADD -> REPLACE """ valid_instructions = ('KEEP', 'REMOVE', 'ADD', 'UPDATE') def _get_all_nested_diff_instructions(diffpart): "Started for each root key, returns all instructions nested under it" out = [] typ = type(diffpart) if typ == tuple and len(diffpart) == 3 and diffpart[2] in valid_instructions: out = [diffpart[2]] elif typ == dict: # all other are dicts for val in diffpart.values(): out.extend(_get_all_nested_diff_instructions(val)) else: raise RuntimeError("Diff contains non-dicts that are not on the " "form (old, new, inst): {}".format(diffpart)) return out flat_diff = {} # flatten diff based on rules for rootkey, diffpart in diff.items(): insts = _get_all_nested_diff_instructions(diffpart) if all(inst == "KEEP" for inst in insts): rootinst = "KEEP" elif all(inst in ("ADD", "UPDATE") for inst in insts): rootinst = "UPDATE" elif all(inst == "REMOVE" for inst in insts): rootinst = "REMOVE" elif "REMOVE" in insts: rootinst = "REPLACE" else: rootinst = "UPDATE" flat_diff[rootkey] = rootinst return flat_diff
[ "def", "flatten_diff", "(", "diff", ")", ":", "valid_instructions", "=", "(", "'KEEP'", ",", "'REMOVE'", ",", "'ADD'", ",", "'UPDATE'", ")", "def", "_get_all_nested_diff_instructions", "(", "diffpart", ")", ":", "\"Started for each root key, returns all instructions nested under it\"", "out", "=", "[", "]", "typ", "=", "type", "(", "diffpart", ")", "if", "typ", "==", "tuple", "and", "len", "(", "diffpart", ")", "==", "3", "and", "diffpart", "[", "2", "]", "in", "valid_instructions", ":", "out", "=", "[", "diffpart", "[", "2", "]", "]", "elif", "typ", "==", "dict", ":", "# all other are dicts", "for", "val", "in", "diffpart", ".", "values", "(", ")", ":", "out", ".", "extend", "(", "_get_all_nested_diff_instructions", "(", "val", ")", ")", "else", ":", "raise", "RuntimeError", "(", "\"Diff contains non-dicts that are not on the \"", "\"form (old, new, inst): {}\"", ".", "format", "(", "diffpart", ")", ")", "return", "out", "flat_diff", "=", "{", "}", "# flatten diff based on rules", "for", "rootkey", ",", "diffpart", "in", "diff", ".", "items", "(", ")", ":", "insts", "=", "_get_all_nested_diff_instructions", "(", "diffpart", ")", "if", "all", "(", "inst", "==", "\"KEEP\"", "for", "inst", "in", "insts", ")", ":", "rootinst", "=", "\"KEEP\"", "elif", "all", "(", "inst", "in", "(", "\"ADD\"", ",", "\"UPDATE\"", ")", "for", "inst", "in", "insts", ")", ":", "rootinst", "=", "\"UPDATE\"", "elif", "all", "(", "inst", "==", "\"REMOVE\"", "for", "inst", "in", "insts", ")", ":", "rootinst", "=", "\"REMOVE\"", "elif", "\"REMOVE\"", "in", "insts", ":", "rootinst", "=", "\"REPLACE\"", "else", ":", "rootinst", "=", "\"UPDATE\"", "flat_diff", "[", "rootkey", "]", "=", "rootinst", "return", "flat_diff" ]
[ 336, 0 ]
[ 399, 20 ]
python
en
['en', 'error', 'th']
False
prototype_diff_from_object
(prototype, obj)
Get a simple diff for a prototype compared to an object which may or may not already have a prototype (or has one but changed locally). For more complex migratations a manual diff may be needed. Args: prototype (dict): New prototype. obj (Object): Object to compare prototype against. Returns: diff (dict): Mapping for every prototype key: {"keyname": "REMOVE|UPDATE|KEEP", ...} obj_prototype (dict): The prototype calculated for the given object. The diff is how to convert this prototype into the new prototype. Notes: The `diff` is on the following form: {"key": (old, new, "KEEP|REPLACE|UPDATE|REMOVE"), "attrs": {"attrkey": (old, new, "KEEP|REPLACE|UPDATE|REMOVE"), "attrkey": (old, new, "KEEP|REPLACE|UPDATE|REMOVE"), ...}, "aliases": {"aliasname": (old, new, "KEEP...", ...}, ... }
Get a simple diff for a prototype compared to an object which may or may not already have a prototype (or has one but changed locally). For more complex migratations a manual diff may be needed.
def prototype_diff_from_object(prototype, obj): """ Get a simple diff for a prototype compared to an object which may or may not already have a prototype (or has one but changed locally). For more complex migratations a manual diff may be needed. Args: prototype (dict): New prototype. obj (Object): Object to compare prototype against. Returns: diff (dict): Mapping for every prototype key: {"keyname": "REMOVE|UPDATE|KEEP", ...} obj_prototype (dict): The prototype calculated for the given object. The diff is how to convert this prototype into the new prototype. Notes: The `diff` is on the following form: {"key": (old, new, "KEEP|REPLACE|UPDATE|REMOVE"), "attrs": {"attrkey": (old, new, "KEEP|REPLACE|UPDATE|REMOVE"), "attrkey": (old, new, "KEEP|REPLACE|UPDATE|REMOVE"), ...}, "aliases": {"aliasname": (old, new, "KEEP...", ...}, ... } """ obj_prototype = prototype_from_object(obj) diff = prototype_diff(obj_prototype, protlib.homogenize_prototype(prototype)) return diff, obj_prototype
[ "def", "prototype_diff_from_object", "(", "prototype", ",", "obj", ")", ":", "obj_prototype", "=", "prototype_from_object", "(", "obj", ")", "diff", "=", "prototype_diff", "(", "obj_prototype", ",", "protlib", ".", "homogenize_prototype", "(", "prototype", ")", ")", "return", "diff", ",", "obj_prototype" ]
[ 402, 0 ]
[ 429, 30 ]
python
en
['en', 'error', 'th']
False
batch_update_objects_with_prototype
(prototype, diff=None, objects=None)
Update existing objects with the latest version of the prototype. Args: prototype (str or dict): Either the `prototype_key` to use or the prototype dict itself. diff (dict, optional): This a diff structure that describes how to update the protototype. If not given this will be constructed from the first object found. objects (list, optional): List of objects to update. If not given, query for these objects using the prototype's `prototype_key`. Returns: changed (int): The number of objects that had changes applied to them.
Update existing objects with the latest version of the prototype.
def batch_update_objects_with_prototype(prototype, diff=None, objects=None): """ Update existing objects with the latest version of the prototype. Args: prototype (str or dict): Either the `prototype_key` to use or the prototype dict itself. diff (dict, optional): This a diff structure that describes how to update the protototype. If not given this will be constructed from the first object found. objects (list, optional): List of objects to update. If not given, query for these objects using the prototype's `prototype_key`. Returns: changed (int): The number of objects that had changes applied to them. """ prototype = protlib.homogenize_prototype(prototype) if isinstance(prototype, basestring): new_prototype = protlib.search_prototype(prototype) else: new_prototype = prototype prototype_key = new_prototype['prototype_key'] if not objects: objects = ObjectDB.objects.get_by_tag(prototype_key, category=_PROTOTYPE_TAG_CATEGORY) if not objects: return 0 if not diff: diff, _ = prototype_diff_from_object(new_prototype, objects[0]) # make sure the diff is flattened diff = flatten_diff(diff) changed = 0 for obj in objects: do_save = False old_prot_key = obj.tags.get(category=_PROTOTYPE_TAG_CATEGORY, return_list=True) old_prot_key = old_prot_key[0] if old_prot_key else None if prototype_key != old_prot_key: obj.tags.clear(category=_PROTOTYPE_TAG_CATEGORY) obj.tags.add(prototype_key, category=_PROTOTYPE_TAG_CATEGORY) for key, directive in diff.items(): if directive in ('UPDATE', 'REPLACE'): if key in _PROTOTYPE_META_NAMES: # prototype meta keys are not stored on-object continue val = new_prototype[key] do_save = True if key == 'key': obj.db_key = init_spawn_value(val, str) elif key == 'typeclass': obj.db_typeclass_path = init_spawn_value(val, str) elif key == 'location': obj.db_location = init_spawn_value(val, value_to_obj) elif key == 'home': obj.db_home = init_spawn_value(val, value_to_obj) elif key == 'destination': obj.db_destination = init_spawn_value(val, value_to_obj) elif key == 'locks': if directive == 'REPLACE': obj.locks.clear() obj.locks.add(init_spawn_value(val, str)) elif key == 'permissions': if directive == 'REPLACE': obj.permissions.clear() obj.permissions.batch_add(*(init_spawn_value(perm, str) for perm in val)) elif key == 'aliases': if directive == 'REPLACE': obj.aliases.clear() obj.aliases.batch_add(*(init_spawn_value(alias, str) for alias in val)) elif key == 'tags': if directive == 'REPLACE': obj.tags.clear() obj.tags.batch_add(*( (init_spawn_value(ttag, str), tcategory, tdata) for ttag, tcategory, tdata in val)) elif key == 'attrs': if directive == 'REPLACE': obj.attributes.clear() obj.attributes.batch_add(*( (init_spawn_value(akey, str), init_spawn_value(aval, value_to_obj), acategory, alocks) for akey, aval, acategory, alocks in val)) elif key == 'exec': # we don't auto-rerun exec statements, it would be huge security risk! pass else: obj.attributes.add(key, init_spawn_value(val, value_to_obj)) elif directive == 'REMOVE': do_save = True if key == 'key': obj.db_key = '' elif key == 'typeclass': # fall back to default obj.db_typeclass_path = settings.BASE_OBJECT_TYPECLASS elif key == 'location': obj.db_location = None elif key == 'home': obj.db_home = None elif key == 'destination': obj.db_destination = None elif key == 'locks': obj.locks.clear() elif key == 'permissions': obj.permissions.clear() elif key == 'aliases': obj.aliases.clear() elif key == 'tags': obj.tags.clear() elif key == 'attrs': obj.attributes.clear() elif key == 'exec': # we don't auto-rerun exec statements, it would be huge security risk! pass else: obj.attributes.remove(key) if do_save: changed += 1 obj.save() return changed
[ "def", "batch_update_objects_with_prototype", "(", "prototype", ",", "diff", "=", "None", ",", "objects", "=", "None", ")", ":", "prototype", "=", "protlib", ".", "homogenize_prototype", "(", "prototype", ")", "if", "isinstance", "(", "prototype", ",", "basestring", ")", ":", "new_prototype", "=", "protlib", ".", "search_prototype", "(", "prototype", ")", "else", ":", "new_prototype", "=", "prototype", "prototype_key", "=", "new_prototype", "[", "'prototype_key'", "]", "if", "not", "objects", ":", "objects", "=", "ObjectDB", ".", "objects", ".", "get_by_tag", "(", "prototype_key", ",", "category", "=", "_PROTOTYPE_TAG_CATEGORY", ")", "if", "not", "objects", ":", "return", "0", "if", "not", "diff", ":", "diff", ",", "_", "=", "prototype_diff_from_object", "(", "new_prototype", ",", "objects", "[", "0", "]", ")", "# make sure the diff is flattened", "diff", "=", "flatten_diff", "(", "diff", ")", "changed", "=", "0", "for", "obj", "in", "objects", ":", "do_save", "=", "False", "old_prot_key", "=", "obj", ".", "tags", ".", "get", "(", "category", "=", "_PROTOTYPE_TAG_CATEGORY", ",", "return_list", "=", "True", ")", "old_prot_key", "=", "old_prot_key", "[", "0", "]", "if", "old_prot_key", "else", "None", "if", "prototype_key", "!=", "old_prot_key", ":", "obj", ".", "tags", ".", "clear", "(", "category", "=", "_PROTOTYPE_TAG_CATEGORY", ")", "obj", ".", "tags", ".", "add", "(", "prototype_key", ",", "category", "=", "_PROTOTYPE_TAG_CATEGORY", ")", "for", "key", ",", "directive", "in", "diff", ".", "items", "(", ")", ":", "if", "directive", "in", "(", "'UPDATE'", ",", "'REPLACE'", ")", ":", "if", "key", "in", "_PROTOTYPE_META_NAMES", ":", "# prototype meta keys are not stored on-object", "continue", "val", "=", "new_prototype", "[", "key", "]", "do_save", "=", "True", "if", "key", "==", "'key'", ":", "obj", ".", "db_key", "=", "init_spawn_value", "(", "val", ",", "str", ")", "elif", "key", "==", "'typeclass'", ":", "obj", ".", "db_typeclass_path", "=", "init_spawn_value", "(", "val", ",", "str", ")", "elif", "key", "==", "'location'", ":", "obj", ".", "db_location", "=", "init_spawn_value", "(", "val", ",", "value_to_obj", ")", "elif", "key", "==", "'home'", ":", "obj", ".", "db_home", "=", "init_spawn_value", "(", "val", ",", "value_to_obj", ")", "elif", "key", "==", "'destination'", ":", "obj", ".", "db_destination", "=", "init_spawn_value", "(", "val", ",", "value_to_obj", ")", "elif", "key", "==", "'locks'", ":", "if", "directive", "==", "'REPLACE'", ":", "obj", ".", "locks", ".", "clear", "(", ")", "obj", ".", "locks", ".", "add", "(", "init_spawn_value", "(", "val", ",", "str", ")", ")", "elif", "key", "==", "'permissions'", ":", "if", "directive", "==", "'REPLACE'", ":", "obj", ".", "permissions", ".", "clear", "(", ")", "obj", ".", "permissions", ".", "batch_add", "(", "*", "(", "init_spawn_value", "(", "perm", ",", "str", ")", "for", "perm", "in", "val", ")", ")", "elif", "key", "==", "'aliases'", ":", "if", "directive", "==", "'REPLACE'", ":", "obj", ".", "aliases", ".", "clear", "(", ")", "obj", ".", "aliases", ".", "batch_add", "(", "*", "(", "init_spawn_value", "(", "alias", ",", "str", ")", "for", "alias", "in", "val", ")", ")", "elif", "key", "==", "'tags'", ":", "if", "directive", "==", "'REPLACE'", ":", "obj", ".", "tags", ".", "clear", "(", ")", "obj", ".", "tags", ".", "batch_add", "(", "*", "(", "(", "init_spawn_value", "(", "ttag", ",", "str", ")", ",", "tcategory", ",", "tdata", ")", "for", "ttag", ",", "tcategory", ",", "tdata", "in", "val", ")", ")", "elif", "key", "==", "'attrs'", ":", "if", "directive", "==", "'REPLACE'", ":", "obj", ".", "attributes", ".", "clear", "(", ")", "obj", ".", "attributes", ".", "batch_add", "(", "*", "(", "(", "init_spawn_value", "(", "akey", ",", "str", ")", ",", "init_spawn_value", "(", "aval", ",", "value_to_obj", ")", ",", "acategory", ",", "alocks", ")", "for", "akey", ",", "aval", ",", "acategory", ",", "alocks", "in", "val", ")", ")", "elif", "key", "==", "'exec'", ":", "# we don't auto-rerun exec statements, it would be huge security risk!", "pass", "else", ":", "obj", ".", "attributes", ".", "add", "(", "key", ",", "init_spawn_value", "(", "val", ",", "value_to_obj", ")", ")", "elif", "directive", "==", "'REMOVE'", ":", "do_save", "=", "True", "if", "key", "==", "'key'", ":", "obj", ".", "db_key", "=", "''", "elif", "key", "==", "'typeclass'", ":", "# fall back to default", "obj", ".", "db_typeclass_path", "=", "settings", ".", "BASE_OBJECT_TYPECLASS", "elif", "key", "==", "'location'", ":", "obj", ".", "db_location", "=", "None", "elif", "key", "==", "'home'", ":", "obj", ".", "db_home", "=", "None", "elif", "key", "==", "'destination'", ":", "obj", ".", "db_destination", "=", "None", "elif", "key", "==", "'locks'", ":", "obj", ".", "locks", ".", "clear", "(", ")", "elif", "key", "==", "'permissions'", ":", "obj", ".", "permissions", ".", "clear", "(", ")", "elif", "key", "==", "'aliases'", ":", "obj", ".", "aliases", ".", "clear", "(", ")", "elif", "key", "==", "'tags'", ":", "obj", ".", "tags", ".", "clear", "(", ")", "elif", "key", "==", "'attrs'", ":", "obj", ".", "attributes", ".", "clear", "(", ")", "elif", "key", "==", "'exec'", ":", "# we don't auto-rerun exec statements, it would be huge security risk!", "pass", "else", ":", "obj", ".", "attributes", ".", "remove", "(", "key", ")", "if", "do_save", ":", "changed", "+=", "1", "obj", ".", "save", "(", ")", "return", "changed" ]
[ 432, 0 ]
[ 561, 18 ]
python
en
['en', 'error', 'th']
False
batch_create_object
(*objparams)
This is a cut-down version of the create_object() function, optimized for speed. It does NOT check and convert various input so make sure the spawned Typeclass works before using this! Args: objsparams (tuple): Each paremter tuple will create one object instance using the parameters within. The parameters should be given in the following order: - `create_kwargs` (dict): For use as new_obj = `ObjectDB(**create_kwargs)`. - `permissions` (str): Permission string used with `new_obj.batch_add(permission)`. - `lockstring` (str): Lockstring used with `new_obj.locks.add(lockstring)`. - `aliases` (list): A list of alias strings for adding with `new_object.aliases.batch_add(*aliases)`. - `nattributes` (list): list of tuples `(key, value)` to be loop-added to add with `new_obj.nattributes.add(*tuple)`. - `attributes` (list): list of tuples `(key, value[,category[,lockstring]])` for adding with `new_obj.attributes.batch_add(*attributes)`. - `tags` (list): list of tuples `(key, category)` for adding with `new_obj.tags.batch_add(*tags)`. - `execs` (list): Code strings to execute together with the creation of each object. They will be executed with `evennia` and `obj` (the newly created object) available in the namespace. Execution will happend after all other properties have been assigned and is intended for calling custom handlers etc. Returns: objects (list): A list of created objects Notes: The `exec` list will execute arbitrary python code so don't allow this to be available to unprivileged users!
This is a cut-down version of the create_object() function, optimized for speed. It does NOT check and convert various input so make sure the spawned Typeclass works before using this!
def batch_create_object(*objparams): """ This is a cut-down version of the create_object() function, optimized for speed. It does NOT check and convert various input so make sure the spawned Typeclass works before using this! Args: objsparams (tuple): Each paremter tuple will create one object instance using the parameters within. The parameters should be given in the following order: - `create_kwargs` (dict): For use as new_obj = `ObjectDB(**create_kwargs)`. - `permissions` (str): Permission string used with `new_obj.batch_add(permission)`. - `lockstring` (str): Lockstring used with `new_obj.locks.add(lockstring)`. - `aliases` (list): A list of alias strings for adding with `new_object.aliases.batch_add(*aliases)`. - `nattributes` (list): list of tuples `(key, value)` to be loop-added to add with `new_obj.nattributes.add(*tuple)`. - `attributes` (list): list of tuples `(key, value[,category[,lockstring]])` for adding with `new_obj.attributes.batch_add(*attributes)`. - `tags` (list): list of tuples `(key, category)` for adding with `new_obj.tags.batch_add(*tags)`. - `execs` (list): Code strings to execute together with the creation of each object. They will be executed with `evennia` and `obj` (the newly created object) available in the namespace. Execution will happend after all other properties have been assigned and is intended for calling custom handlers etc. Returns: objects (list): A list of created objects Notes: The `exec` list will execute arbitrary python code so don't allow this to be available to unprivileged users! """ # bulk create all objects in one go # unfortunately this doesn't work since bulk_create doesn't creates pks; # the result would be duplicate objects at the next stage, so we comment # it out for now: # dbobjs = _ObjectDB.objects.bulk_create(dbobjs) dbobjs = [ObjectDB(**objparam[0]) for objparam in objparams] objs = [] for iobj, obj in enumerate(dbobjs): # call all setup hooks on each object objparam = objparams[iobj] # setup obj._createdict = {"permissions": make_iter(objparam[1]), "locks": objparam[2], "aliases": make_iter(objparam[3]), "nattributes": objparam[4], "attributes": objparam[5], "tags": make_iter(objparam[6])} # this triggers all hooks obj.save() # run eventual extra code for code in objparam[7]: if code: exec(code, {}, {"evennia": evennia, "obj": obj}) objs.append(obj) return objs
[ "def", "batch_create_object", "(", "*", "objparams", ")", ":", "# bulk create all objects in one go", "# unfortunately this doesn't work since bulk_create doesn't creates pks;", "# the result would be duplicate objects at the next stage, so we comment", "# it out for now:", "# dbobjs = _ObjectDB.objects.bulk_create(dbobjs)", "dbobjs", "=", "[", "ObjectDB", "(", "*", "*", "objparam", "[", "0", "]", ")", "for", "objparam", "in", "objparams", "]", "objs", "=", "[", "]", "for", "iobj", ",", "obj", "in", "enumerate", "(", "dbobjs", ")", ":", "# call all setup hooks on each object", "objparam", "=", "objparams", "[", "iobj", "]", "# setup", "obj", ".", "_createdict", "=", "{", "\"permissions\"", ":", "make_iter", "(", "objparam", "[", "1", "]", ")", ",", "\"locks\"", ":", "objparam", "[", "2", "]", ",", "\"aliases\"", ":", "make_iter", "(", "objparam", "[", "3", "]", ")", ",", "\"nattributes\"", ":", "objparam", "[", "4", "]", ",", "\"attributes\"", ":", "objparam", "[", "5", "]", ",", "\"tags\"", ":", "make_iter", "(", "objparam", "[", "6", "]", ")", "}", "# this triggers all hooks", "obj", ".", "save", "(", ")", "# run eventual extra code", "for", "code", "in", "objparam", "[", "7", "]", ":", "if", "code", ":", "exec", "(", "code", ",", "{", "}", ",", "{", "\"evennia\"", ":", "evennia", ",", "\"obj\"", ":", "obj", "}", ")", "objs", ".", "append", "(", "obj", ")", "return", "objs" ]
[ 564, 0 ]
[ 626, 15 ]
python
en
['en', 'error', 'th']
False
spawn
(*prototypes, **kwargs)
Spawn a number of prototyped objects. Args: prototypes (dict): Each argument should be a prototype dictionary. Kwargs: prototype_modules (str or list): A python-path to a prototype module, or a list of such paths. These will be used to build the global protparents dictionary accessible by the input prototypes. If not given, it will instead look for modules defined by settings.PROTOTYPE_MODULES. prototype_parents (dict): A dictionary holding a custom prototype-parent dictionary. Will overload same-named prototypes from prototype_modules. return_parents (bool): Only return a dict of the prototype-parents (no object creation happens) only_validate (bool): Only run validation of prototype/parents (no object creation) and return the create-kwargs. Returns: object (Object, dict or list): Spawned object(s). If `only_validate` is given, return a list of the creation kwargs to build the object(s) without actually creating it. If `return_parents` is set, instead return dict of prototype parents.
Spawn a number of prototyped objects.
def spawn(*prototypes, **kwargs): """ Spawn a number of prototyped objects. Args: prototypes (dict): Each argument should be a prototype dictionary. Kwargs: prototype_modules (str or list): A python-path to a prototype module, or a list of such paths. These will be used to build the global protparents dictionary accessible by the input prototypes. If not given, it will instead look for modules defined by settings.PROTOTYPE_MODULES. prototype_parents (dict): A dictionary holding a custom prototype-parent dictionary. Will overload same-named prototypes from prototype_modules. return_parents (bool): Only return a dict of the prototype-parents (no object creation happens) only_validate (bool): Only run validation of prototype/parents (no object creation) and return the create-kwargs. Returns: object (Object, dict or list): Spawned object(s). If `only_validate` is given, return a list of the creation kwargs to build the object(s) without actually creating it. If `return_parents` is set, instead return dict of prototype parents. """ # get available protparents protparents = {prot['prototype_key'].lower(): prot for prot in protlib.search_prototype()} if not kwargs.get("only_validate"): # homogenization to be more lenient about prototype format when entering the prototype manually prototypes = [protlib.homogenize_prototype(prot) for prot in prototypes] # overload module's protparents with specifically given protparents # we allow prototype_key to be the key of the protparent dict, to allow for module-level # prototype imports. We need to insert prototype_key in this case for key, protparent in kwargs.get("prototype_parents", {}).items(): key = str(key).lower() protparent['prototype_key'] = str(protparent.get("prototype_key", key)).lower() protparents[key] = protparent if "return_parents" in kwargs: # only return the parents return copy.deepcopy(protparents) objsparams = [] for prototype in prototypes: protlib.validate_prototype(prototype, None, protparents, is_prototype_base=True) prot = _get_prototype(prototype, protparents, uninherited={"prototype_key": prototype.get("prototype_key")}) if not prot: continue # extract the keyword args we need to create the object itself. If we get a callable, # call that to get the value (don't catch errors) create_kwargs = {} # we must always add a key, so if not given we use a shortened md5 hash. There is a (small) # chance this is not unique but it should usually not be a problem. val = prot.pop("key", "Spawned-{}".format( hashlib.md5(str(time.time())).hexdigest()[:6])) create_kwargs["db_key"] = init_spawn_value(val, str) val = prot.pop("location", None) create_kwargs["db_location"] = init_spawn_value(val, value_to_obj) val = prot.pop("home", settings.DEFAULT_HOME) create_kwargs["db_home"] = init_spawn_value(val, value_to_obj) val = prot.pop("destination", None) create_kwargs["db_destination"] = init_spawn_value(val, value_to_obj) val = prot.pop("typeclass", settings.BASE_OBJECT_TYPECLASS) create_kwargs["db_typeclass_path"] = init_spawn_value(val, str) # extract calls to handlers val = prot.pop("permissions", []) permission_string = init_spawn_value(val, make_iter) val = prot.pop("locks", "") lock_string = init_spawn_value(val, str) val = prot.pop("aliases", []) alias_string = init_spawn_value(val, make_iter) val = prot.pop("tags", []) tags = [] for (tag, category, data) in val: tags.append((init_spawn_value(tag, str), category, data)) prototype_key = prototype.get('prototype_key', None) if prototype_key: # we make sure to add a tag identifying which prototype created this object tags.append((prototype_key, _PROTOTYPE_TAG_CATEGORY)) val = prot.pop("exec", "") execs = init_spawn_value(val, make_iter) # extract ndb assignments nattributes = dict((key.split("_", 1)[1], init_spawn_value(val, value_to_obj)) for key, val in prot.items() if key.startswith("ndb_")) # the rest are attribute tuples (attrname, value, category, locks) val = make_iter(prot.pop("attrs", [])) attributes = [] for (attrname, value, category, locks) in val: attributes.append((attrname, init_spawn_value(value), category, locks)) simple_attributes = [] for key, value in ((key, value) for key, value in prot.items() if not (key.startswith("ndb_"))): # we don't support categories, nor locks for simple attributes if key in _PROTOTYPE_META_NAMES: continue else: simple_attributes.append( (key, init_spawn_value(value, value_to_obj_or_any), None, None)) attributes = attributes + simple_attributes attributes = [tup for tup in attributes if not tup[0] in _NON_CREATE_KWARGS] # pack for call into _batch_create_object objsparams.append((create_kwargs, permission_string, lock_string, alias_string, nattributes, attributes, tags, execs)) if kwargs.get("only_validate"): return objsparams return batch_create_object(*objsparams)
[ "def", "spawn", "(", "*", "prototypes", ",", "*", "*", "kwargs", ")", ":", "# get available protparents", "protparents", "=", "{", "prot", "[", "'prototype_key'", "]", ".", "lower", "(", ")", ":", "prot", "for", "prot", "in", "protlib", ".", "search_prototype", "(", ")", "}", "if", "not", "kwargs", ".", "get", "(", "\"only_validate\"", ")", ":", "# homogenization to be more lenient about prototype format when entering the prototype manually", "prototypes", "=", "[", "protlib", ".", "homogenize_prototype", "(", "prot", ")", "for", "prot", "in", "prototypes", "]", "# overload module's protparents with specifically given protparents", "# we allow prototype_key to be the key of the protparent dict, to allow for module-level", "# prototype imports. We need to insert prototype_key in this case", "for", "key", ",", "protparent", "in", "kwargs", ".", "get", "(", "\"prototype_parents\"", ",", "{", "}", ")", ".", "items", "(", ")", ":", "key", "=", "str", "(", "key", ")", ".", "lower", "(", ")", "protparent", "[", "'prototype_key'", "]", "=", "str", "(", "protparent", ".", "get", "(", "\"prototype_key\"", ",", "key", ")", ")", ".", "lower", "(", ")", "protparents", "[", "key", "]", "=", "protparent", "if", "\"return_parents\"", "in", "kwargs", ":", "# only return the parents", "return", "copy", ".", "deepcopy", "(", "protparents", ")", "objsparams", "=", "[", "]", "for", "prototype", "in", "prototypes", ":", "protlib", ".", "validate_prototype", "(", "prototype", ",", "None", ",", "protparents", ",", "is_prototype_base", "=", "True", ")", "prot", "=", "_get_prototype", "(", "prototype", ",", "protparents", ",", "uninherited", "=", "{", "\"prototype_key\"", ":", "prototype", ".", "get", "(", "\"prototype_key\"", ")", "}", ")", "if", "not", "prot", ":", "continue", "# extract the keyword args we need to create the object itself. If we get a callable,", "# call that to get the value (don't catch errors)", "create_kwargs", "=", "{", "}", "# we must always add a key, so if not given we use a shortened md5 hash. There is a (small)", "# chance this is not unique but it should usually not be a problem.", "val", "=", "prot", ".", "pop", "(", "\"key\"", ",", "\"Spawned-{}\"", ".", "format", "(", "hashlib", ".", "md5", "(", "str", "(", "time", ".", "time", "(", ")", ")", ")", ".", "hexdigest", "(", ")", "[", ":", "6", "]", ")", ")", "create_kwargs", "[", "\"db_key\"", "]", "=", "init_spawn_value", "(", "val", ",", "str", ")", "val", "=", "prot", ".", "pop", "(", "\"location\"", ",", "None", ")", "create_kwargs", "[", "\"db_location\"", "]", "=", "init_spawn_value", "(", "val", ",", "value_to_obj", ")", "val", "=", "prot", ".", "pop", "(", "\"home\"", ",", "settings", ".", "DEFAULT_HOME", ")", "create_kwargs", "[", "\"db_home\"", "]", "=", "init_spawn_value", "(", "val", ",", "value_to_obj", ")", "val", "=", "prot", ".", "pop", "(", "\"destination\"", ",", "None", ")", "create_kwargs", "[", "\"db_destination\"", "]", "=", "init_spawn_value", "(", "val", ",", "value_to_obj", ")", "val", "=", "prot", ".", "pop", "(", "\"typeclass\"", ",", "settings", ".", "BASE_OBJECT_TYPECLASS", ")", "create_kwargs", "[", "\"db_typeclass_path\"", "]", "=", "init_spawn_value", "(", "val", ",", "str", ")", "# extract calls to handlers", "val", "=", "prot", ".", "pop", "(", "\"permissions\"", ",", "[", "]", ")", "permission_string", "=", "init_spawn_value", "(", "val", ",", "make_iter", ")", "val", "=", "prot", ".", "pop", "(", "\"locks\"", ",", "\"\"", ")", "lock_string", "=", "init_spawn_value", "(", "val", ",", "str", ")", "val", "=", "prot", ".", "pop", "(", "\"aliases\"", ",", "[", "]", ")", "alias_string", "=", "init_spawn_value", "(", "val", ",", "make_iter", ")", "val", "=", "prot", ".", "pop", "(", "\"tags\"", ",", "[", "]", ")", "tags", "=", "[", "]", "for", "(", "tag", ",", "category", ",", "data", ")", "in", "val", ":", "tags", ".", "append", "(", "(", "init_spawn_value", "(", "tag", ",", "str", ")", ",", "category", ",", "data", ")", ")", "prototype_key", "=", "prototype", ".", "get", "(", "'prototype_key'", ",", "None", ")", "if", "prototype_key", ":", "# we make sure to add a tag identifying which prototype created this object", "tags", ".", "append", "(", "(", "prototype_key", ",", "_PROTOTYPE_TAG_CATEGORY", ")", ")", "val", "=", "prot", ".", "pop", "(", "\"exec\"", ",", "\"\"", ")", "execs", "=", "init_spawn_value", "(", "val", ",", "make_iter", ")", "# extract ndb assignments", "nattributes", "=", "dict", "(", "(", "key", ".", "split", "(", "\"_\"", ",", "1", ")", "[", "1", "]", ",", "init_spawn_value", "(", "val", ",", "value_to_obj", ")", ")", "for", "key", ",", "val", "in", "prot", ".", "items", "(", ")", "if", "key", ".", "startswith", "(", "\"ndb_\"", ")", ")", "# the rest are attribute tuples (attrname, value, category, locks)", "val", "=", "make_iter", "(", "prot", ".", "pop", "(", "\"attrs\"", ",", "[", "]", ")", ")", "attributes", "=", "[", "]", "for", "(", "attrname", ",", "value", ",", "category", ",", "locks", ")", "in", "val", ":", "attributes", ".", "append", "(", "(", "attrname", ",", "init_spawn_value", "(", "value", ")", ",", "category", ",", "locks", ")", ")", "simple_attributes", "=", "[", "]", "for", "key", ",", "value", "in", "(", "(", "key", ",", "value", ")", "for", "key", ",", "value", "in", "prot", ".", "items", "(", ")", "if", "not", "(", "key", ".", "startswith", "(", "\"ndb_\"", ")", ")", ")", ":", "# we don't support categories, nor locks for simple attributes", "if", "key", "in", "_PROTOTYPE_META_NAMES", ":", "continue", "else", ":", "simple_attributes", ".", "append", "(", "(", "key", ",", "init_spawn_value", "(", "value", ",", "value_to_obj_or_any", ")", ",", "None", ",", "None", ")", ")", "attributes", "=", "attributes", "+", "simple_attributes", "attributes", "=", "[", "tup", "for", "tup", "in", "attributes", "if", "not", "tup", "[", "0", "]", "in", "_NON_CREATE_KWARGS", "]", "# pack for call into _batch_create_object", "objsparams", ".", "append", "(", "(", "create_kwargs", ",", "permission_string", ",", "lock_string", ",", "alias_string", ",", "nattributes", ",", "attributes", ",", "tags", ",", "execs", ")", ")", "if", "kwargs", ".", "get", "(", "\"only_validate\"", ")", ":", "return", "objsparams", "return", "batch_create_object", "(", "*", "objsparams", ")" ]
[ 631, 0 ]
[ 757, 43 ]
python
en
['en', 'error', 'th']
False
differentiable_air_to_obj_vapor_flux
(vapor_pressure_1: float, vapor_pressure_2: float, heat_exchange_coef: float)
Equation 8.44 Args: vapor_pressure_1: the vapor pressure of the air of location 1 [Pa] vapor_pressure_2: the saturated vapor pressure of object 2 at its temperature [Pa] heat_exchange_coef: heat exchange coefficient between the air of location 1 to object 2 [W m^-2 K^-1] Returns: the vapor flux from the air to an object by condensation [kg m^-2 s^-1]
Equation 8.44 Args: vapor_pressure_1: the vapor pressure of the air of location 1 [Pa] vapor_pressure_2: the saturated vapor pressure of object 2 at its temperature [Pa] heat_exchange_coef: heat exchange coefficient between the air of location 1 to object 2 [W m^-2 K^-1]
def differentiable_air_to_obj_vapor_flux(vapor_pressure_1: float, vapor_pressure_2: float, heat_exchange_coef: float): """ Equation 8.44 Args: vapor_pressure_1: the vapor pressure of the air of location 1 [Pa] vapor_pressure_2: the saturated vapor pressure of object 2 at its temperature [Pa] heat_exchange_coef: heat exchange coefficient between the air of location 1 to object 2 [W m^-2 K^-1] Returns: the vapor flux from the air to an object by condensation [kg m^-2 s^-1] """ return 6.4E-9 * heat_exchange_coef * (vapor_pressure_1 - vapor_pressure_2) \ / (1 + math.exp(S_MV12 * (vapor_pressure_1 - vapor_pressure_2)))
[ "def", "differentiable_air_to_obj_vapor_flux", "(", "vapor_pressure_1", ":", "float", ",", "vapor_pressure_2", ":", "float", ",", "heat_exchange_coef", ":", "float", ")", ":", "return", "6.4E-9", "*", "heat_exchange_coef", "*", "(", "vapor_pressure_1", "-", "vapor_pressure_2", ")", "/", "(", "1", "+", "math", ".", "exp", "(", "S_MV12", "*", "(", "vapor_pressure_1", "-", "vapor_pressure_2", ")", ")", ")" ]
[ 4, 0 ]
[ 15, 75 ]
python
en
['en', 'error', 'th']
False
general_vapor_flux
(air_flux: float, vapor_pressure_1: float, vapor_pressure_2: float, temp_1: float, temp_2: float)
Equation 8.45 Args: air_flux: the air flux from location 1 to location 2 vapor_pressure_1: the vapor pressure of the air of location 1 [Pa] vapor_pressure_2: the vapor pressure of the air of location 2 [Pa] temp_1: the temperature at location 1 (°C) temp_2: the temperature at location 2 (°C) Returns: vapour flux from location 1 to location 2 [kg m^-2 s^-1]
Equation 8.45 Args: air_flux: the air flux from location 1 to location 2 vapor_pressure_1: the vapor pressure of the air of location 1 [Pa] vapor_pressure_2: the vapor pressure of the air of location 2 [Pa] temp_1: the temperature at location 1 (°C) temp_2: the temperature at location 2 (°C)
def general_vapor_flux(air_flux: float, vapor_pressure_1: float, vapor_pressure_2: float, temp_1: float, temp_2: float): """ Equation 8.45 Args: air_flux: the air flux from location 1 to location 2 vapor_pressure_1: the vapor pressure of the air of location 1 [Pa] vapor_pressure_2: the vapor pressure of the air of location 2 [Pa] temp_1: the temperature at location 1 (°C) temp_2: the temperature at location 2 (°C) Returns: vapour flux from location 1 to location 2 [kg m^-2 s^-1] """ return M_WATER * air_flux * (vapor_pressure_1 / (temp_1 + 273.15) + vapor_pressure_2 / (temp_2 + 273.15)) / M_GAS
[ "def", "general_vapor_flux", "(", "air_flux", ":", "float", ",", "vapor_pressure_1", ":", "float", ",", "vapor_pressure_2", ":", "float", ",", "temp_1", ":", "float", ",", "temp_2", ":", "float", ")", ":", "return", "M_WATER", "*", "air_flux", "*", "(", "vapor_pressure_1", "/", "(", "temp_1", "+", "273.15", ")", "+", "vapor_pressure_2", "/", "(", "temp_2", "+", "273.15", ")", ")", "/", "M_GAS" ]
[ 18, 0 ]
[ 30, 117 ]
python
en
['en', 'error', 'th']
False
Title.font
(self)
Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute. The 'font' property is an instance of Font that may be specified as: - An instance of :class:`plotly.graph_objs.bar.marker.colorbar.title.Font` - A dict of string/value properties that will be passed to the Font constructor Supported dict properties: color family 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 if they aren't available on the system. The Chart Studio Cloud (at https://chart-studio.plotly.com or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include "Arial", "Balto", "Courier New", "Droid Sans",, "Droid Serif", "Droid Sans Mono", "Gravitas One", "Old Standard TT", "Open Sans", "Overpass", "PT Sans Narrow", "Raleway", "Times New Roman". size Returns ------- plotly.graph_objs.bar.marker.colorbar.title.Font
Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute. The 'font' property is an instance of Font that may be specified as: - An instance of :class:`plotly.graph_objs.bar.marker.colorbar.title.Font` - A dict of string/value properties that will be passed to the Font constructor Supported dict properties: color family 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 if they aren't available on the system. The Chart Studio Cloud (at https://chart-studio.plotly.com or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include "Arial", "Balto", "Courier New", "Droid Sans",, "Droid Serif", "Droid Sans Mono", "Gravitas One", "Old Standard TT", "Open Sans", "Overpass", "PT Sans Narrow", "Raleway", "Times New Roman". size
def font(self): """ Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute. The 'font' property is an instance of Font that may be specified as: - An instance of :class:`plotly.graph_objs.bar.marker.colorbar.title.Font` - A dict of string/value properties that will be passed to the Font constructor Supported dict properties: color family 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 if they aren't available on the system. The Chart Studio Cloud (at https://chart-studio.plotly.com or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include "Arial", "Balto", "Courier New", "Droid Sans",, "Droid Serif", "Droid Sans Mono", "Gravitas One", "Old Standard TT", "Open Sans", "Overpass", "PT Sans Narrow", "Raleway", "Times New Roman". size Returns ------- plotly.graph_objs.bar.marker.colorbar.title.Font """ return self["font"]
[ "def", "font", "(", "self", ")", ":", "return", "self", "[", "\"font\"", "]" ]
[ 15, 4 ]
[ 53, 27 ]
python
en
['en', 'error', 'th']
False
Title.side
(self)
Determines the location of color bar's title with respect to the color bar. Note that the title's location used to be set by the now deprecated `titleside` attribute. The 'side' property is an enumeration that may be specified as: - One of the following enumeration values: ['right', 'top', 'bottom'] Returns ------- Any
Determines the location of color bar's title with respect to the color bar. Note that the title's location used to be set by the now deprecated `titleside` attribute. The 'side' property is an enumeration that may be specified as: - One of the following enumeration values: ['right', 'top', 'bottom']
def side(self): """ Determines the location of color bar's title with respect to the color bar. Note that the title's location used to be set by the now deprecated `titleside` attribute. The 'side' property is an enumeration that may be specified as: - One of the following enumeration values: ['right', 'top', 'bottom'] Returns ------- Any """ return self["side"]
[ "def", "side", "(", "self", ")", ":", "return", "self", "[", "\"side\"", "]" ]
[ 62, 4 ]
[ 76, 27 ]
python
en
['en', 'error', 'th']
False
Title.text
(self)
Sets the title of the color bar. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated. The 'text' property is a string and must be specified as: - A string - A number that will be converted to a string Returns ------- str
Sets the title of the color bar. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated. The 'text' property is a string and must be specified as: - A string - A number that will be converted to a string
def text(self): """ Sets the title of the color bar. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated. The 'text' property is a string and must be specified as: - A string - A number that will be converted to a string Returns ------- str """ return self["text"]
[ "def", "text", "(", "self", ")", ":", "return", "self", "[", "\"text\"", "]" ]
[ 85, 4 ]
[ 99, 27 ]
python
en
['en', 'error', 'th']
False
Title.__init__
(self, arg=None, font=None, side=None, text=None, **kwargs)
Construct a new Title object Parameters ---------- arg dict of properties compatible with this constructor or an instance of :class:`plotly.graph_objs.bar.marker.colorbar.Title` font Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute. side Determines the location of color bar's title with respect to the color bar. Note that the title's location used to be set by the now deprecated `titleside` attribute. text Sets the title of the color bar. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated. Returns ------- Title
Construct a new Title object Parameters ---------- arg dict of properties compatible with this constructor or an instance of :class:`plotly.graph_objs.bar.marker.colorbar.Title` font Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute. side Determines the location of color bar's title with respect to the color bar. Note that the title's location used to be set by the now deprecated `titleside` attribute. text Sets the title of the color bar. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated.
def __init__(self, arg=None, font=None, side=None, text=None, **kwargs): """ Construct a new Title object Parameters ---------- arg dict of properties compatible with this constructor or an instance of :class:`plotly.graph_objs.bar.marker.colorbar.Title` font Sets this color bar's title font. Note that the title's font used to be set by the now deprecated `titlefont` attribute. side Determines the location of color bar's title with respect to the color bar. Note that the title's location used to be set by the now deprecated `titleside` attribute. text Sets the title of the color bar. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated. Returns ------- Title """ super(Title, self).__init__("title") if "_parent" in kwargs: self._parent = kwargs["_parent"] return # Validate arg # ------------ if arg is None: arg = {} elif isinstance(arg, self.__class__): arg = arg.to_plotly_json() elif isinstance(arg, dict): arg = _copy.copy(arg) else: raise ValueError( """\ The first argument to the plotly.graph_objs.bar.marker.colorbar.Title constructor must be a dict or an instance of :class:`plotly.graph_objs.bar.marker.colorbar.Title`""" ) # Handle skip_invalid # ------------------- self._skip_invalid = kwargs.pop("skip_invalid", False) self._validate = kwargs.pop("_validate", True) # Populate data dict with properties # ---------------------------------- _v = arg.pop("font", None) _v = font if font is not None else _v if _v is not None: self["font"] = _v _v = arg.pop("side", None) _v = side if side is not None else _v if _v is not None: self["side"] = _v _v = arg.pop("text", None) _v = text if text is not None else _v if _v is not None: self["text"] = _v # Process unknown kwargs # ---------------------- self._process_kwargs(**dict(arg, **kwargs)) # Reset skip_invalid # ------------------ self._skip_invalid = False
[ "def", "__init__", "(", "self", ",", "arg", "=", "None", ",", "font", "=", "None", ",", "side", "=", "None", ",", "text", "=", "None", ",", "*", "*", "kwargs", ")", ":", "super", "(", "Title", ",", "self", ")", ".", "__init__", "(", "\"title\"", ")", "if", "\"_parent\"", "in", "kwargs", ":", "self", ".", "_parent", "=", "kwargs", "[", "\"_parent\"", "]", "return", "# Validate arg", "# ------------", "if", "arg", "is", "None", ":", "arg", "=", "{", "}", "elif", "isinstance", "(", "arg", ",", "self", ".", "__class__", ")", ":", "arg", "=", "arg", ".", "to_plotly_json", "(", ")", "elif", "isinstance", "(", "arg", ",", "dict", ")", ":", "arg", "=", "_copy", ".", "copy", "(", "arg", ")", "else", ":", "raise", "ValueError", "(", "\"\"\"\\\nThe first argument to the plotly.graph_objs.bar.marker.colorbar.Title \nconstructor must be a dict or \nan instance of :class:`plotly.graph_objs.bar.marker.colorbar.Title`\"\"\"", ")", "# Handle skip_invalid", "# -------------------", "self", ".", "_skip_invalid", "=", "kwargs", ".", "pop", "(", "\"skip_invalid\"", ",", "False", ")", "self", ".", "_validate", "=", "kwargs", ".", "pop", "(", "\"_validate\"", ",", "True", ")", "# Populate data dict with properties", "# ----------------------------------", "_v", "=", "arg", ".", "pop", "(", "\"font\"", ",", "None", ")", "_v", "=", "font", "if", "font", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"font\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"side\"", ",", "None", ")", "_v", "=", "side", "if", "side", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"side\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"text\"", ",", "None", ")", "_v", "=", "text", "if", "text", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"text\"", "]", "=", "_v", "# Process unknown kwargs", "# ----------------------", "self", ".", "_process_kwargs", "(", "*", "*", "dict", "(", "arg", ",", "*", "*", "kwargs", ")", ")", "# Reset skip_invalid", "# ------------------", "self", ".", "_skip_invalid", "=", "False" ]
[ 126, 4 ]
[ 203, 34 ]
python
en
['en', 'error', 'th']
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: aliceblue, antiquewhite, aqua, aquamarine, azure, beige, bisque, black, blanchedalmond, blue, blueviolet, brown, burlywood, cadetblue, chartreuse, chocolate, coral, cornflowerblue, cornsilk, crimson, cyan, darkblue, darkcyan, darkgoldenrod, darkgray, darkgrey, darkgreen, darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred, darksalmon, darkseagreen, darkslateblue, darkslategray, darkslategrey, darkturquoise, darkviolet, deeppink, deepskyblue, dimgray, dimgrey, dodgerblue, firebrick, floralwhite, forestgreen, fuchsia, gainsboro, ghostwhite, gold, goldenrod, gray, grey, green, greenyellow, honeydew, hotpink, indianred, indigo, ivory, khaki, lavender, lavenderblush, lawngreen, lemonchiffon, lightblue, lightcoral, lightcyan, lightgoldenrodyellow, lightgray, lightgrey, lightgreen, lightpink, lightsalmon, lightseagreen, lightskyblue, lightslategray, lightslategrey, lightsteelblue, lightyellow, lime, limegreen, linen, magenta, maroon, mediumaquamarine, mediumblue, mediumorchid, mediumpurple, mediumseagreen, mediumslateblue, mediumspringgreen, mediumturquoise, mediumvioletred, midnightblue, mintcream, mistyrose, moccasin, navajowhite, navy, oldlace, olive, olivedrab, orange, orangered, orchid, palegoldenrod, palegreen, paleturquoise, palevioletred, papayawhip, peachpuff, peru, pink, plum, powderblue, purple, red, rosybrown, royalblue, rebeccapurple, saddlebrown, salmon, sandybrown, seagreen, seashell, sienna, silver, skyblue, slateblue, slategray, slategrey, snow, springgreen, steelblue, tan, teal, thistle, tomato, turquoise, violet, wheat, white, whitesmoke, yellow, yellowgreen - A list or array of any of the above Returns ------- str|numpy.ndarray
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: aliceblue, antiquewhite, aqua, aquamarine, azure, beige, bisque, black, blanchedalmond, blue, blueviolet, brown, burlywood, cadetblue, chartreuse, chocolate, coral, cornflowerblue, cornsilk, crimson, cyan, darkblue, darkcyan, darkgoldenrod, darkgray, darkgrey, darkgreen, darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred, darksalmon, darkseagreen, darkslateblue, darkslategray, darkslategrey, darkturquoise, darkviolet, deeppink, deepskyblue, dimgray, dimgrey, dodgerblue, firebrick, floralwhite, forestgreen, fuchsia, gainsboro, ghostwhite, gold, goldenrod, gray, grey, green, greenyellow, honeydew, hotpink, indianred, indigo, ivory, khaki, lavender, lavenderblush, lawngreen, lemonchiffon, lightblue, lightcoral, lightcyan, lightgoldenrodyellow, lightgray, lightgrey, lightgreen, lightpink, lightsalmon, lightseagreen, lightskyblue, lightslategray, lightslategrey, lightsteelblue, lightyellow, lime, limegreen, linen, magenta, maroon, mediumaquamarine, mediumblue, mediumorchid, mediumpurple, mediumseagreen, mediumslateblue, mediumspringgreen, mediumturquoise, mediumvioletred, midnightblue, mintcream, mistyrose, moccasin, navajowhite, navy, oldlace, olive, olivedrab, orange, orangered, orchid, palegoldenrod, palegreen, paleturquoise, palevioletred, papayawhip, peachpuff, peru, pink, plum, powderblue, purple, red, rosybrown, royalblue, rebeccapurple, saddlebrown, salmon, sandybrown, seagreen, seashell, sienna, silver, skyblue, slateblue, slategray, slategrey, snow, springgreen, steelblue, tan, teal, thistle, tomato, turquoise, violet, wheat, white, whitesmoke, yellow, yellowgreen - A list or array of any of the above
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 named CSS color: aliceblue, antiquewhite, aqua, aquamarine, azure, beige, bisque, black, blanchedalmond, blue, blueviolet, brown, burlywood, cadetblue, chartreuse, chocolate, coral, cornflowerblue, cornsilk, crimson, cyan, darkblue, darkcyan, darkgoldenrod, darkgray, darkgrey, darkgreen, darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred, darksalmon, darkseagreen, darkslateblue, darkslategray, darkslategrey, darkturquoise, darkviolet, deeppink, deepskyblue, dimgray, dimgrey, dodgerblue, firebrick, floralwhite, forestgreen, fuchsia, gainsboro, ghostwhite, gold, goldenrod, gray, grey, green, greenyellow, honeydew, hotpink, indianred, indigo, ivory, khaki, lavender, lavenderblush, lawngreen, lemonchiffon, lightblue, lightcoral, lightcyan, lightgoldenrodyellow, lightgray, lightgrey, lightgreen, lightpink, lightsalmon, lightseagreen, lightskyblue, lightslategray, lightslategrey, lightsteelblue, lightyellow, lime, limegreen, linen, magenta, maroon, mediumaquamarine, mediumblue, mediumorchid, mediumpurple, mediumseagreen, mediumslateblue, mediumspringgreen, mediumturquoise, mediumvioletred, midnightblue, mintcream, mistyrose, moccasin, navajowhite, navy, oldlace, olive, olivedrab, orange, orangered, orchid, palegoldenrod, palegreen, paleturquoise, palevioletred, papayawhip, peachpuff, peru, pink, plum, powderblue, purple, red, rosybrown, royalblue, rebeccapurple, saddlebrown, salmon, sandybrown, seagreen, seashell, sienna, silver, skyblue, slateblue, slategray, slategrey, snow, springgreen, steelblue, tan, teal, thistle, tomato, turquoise, violet, wheat, white, whitesmoke, yellow, yellowgreen - A list or array of any of the above Returns ------- str|numpy.ndarray """ return self["color"]
[ "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 if they aren't available on the system. The Chart Studio Cloud (at https://chart- studio.plotly.com or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include "Arial", "Balto", "Courier New", "Droid Sans",, "Droid Serif", "Droid Sans Mono", "Gravitas One", "Old Standard TT", "Open Sans", "Overpass", "PT Sans Narrow", "Raleway", "Times New Roman". The 'family' property is a string and must be specified as: - A non-empty string - A tuple, list, or one-dimensional numpy array of the above Returns ------- str|numpy.ndarray
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 if they aren't available on the system. The Chart Studio Cloud (at https://chart- studio.plotly.com or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include "Arial", "Balto", "Courier New", "Droid Sans",, "Droid Serif", "Droid Sans Mono", "Gravitas One", "Old Standard TT", "Open Sans", "Overpass", "PT Sans Narrow", "Raleway", "Times New Roman". The 'family' property is a string and must be specified as: - A non-empty string - A tuple, list, or one-dimensional numpy array of the above
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 preference in which to apply fonts if they aren't available on the system. The Chart Studio Cloud (at https://chart- studio.plotly.com or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include "Arial", "Balto", "Courier New", "Droid Sans",, "Droid Serif", "Droid Sans Mono", "Gravitas One", "Old Standard TT", "Open Sans", "Overpass", "PT Sans Narrow", "Raleway", "Times New Roman". The 'family' property is a string and must be specified as: - A non-empty string - A tuple, list, or one-dimensional numpy array of the above Returns ------- str|numpy.ndarray """ return self["family"]
[ "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.scattergl.hoverlabel.Font` color colorsrc Sets the source reference on Chart Studio Cloud for color . family 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 if they aren't available on the system. The Chart Studio Cloud (at https://chart-studio.plotly.com or on- premise) generates images on a server, where only a select number of fonts are installed and supported. These include "Arial", "Balto", "Courier New", "Droid Sans",, "Droid Serif", "Droid Sans Mono", "Gravitas One", "Old Standard TT", "Open Sans", "Overpass", "PT Sans Narrow", "Raleway", "Times New Roman". familysrc Sets the source reference on Chart Studio Cloud for family . size sizesrc Sets the source reference on Chart Studio Cloud for size . Returns ------- Font
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 ---------- arg dict of properties compatible with this constructor or an instance of :class:`plotly.graph_objs.scattergl.hoverlabel.Font` color colorsrc Sets the source reference on Chart Studio Cloud for color . family 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 if they aren't available on the system. The Chart Studio Cloud (at https://chart-studio.plotly.com or on- premise) generates images on a server, where only a select number of fonts are installed and supported. These include "Arial", "Balto", "Courier New", "Droid Sans",, "Droid Serif", "Droid Sans Mono", "Gravitas One", "Old Standard TT", "Open Sans", "Overpass", "PT Sans Narrow", "Raleway", "Times New Roman". familysrc Sets the source reference on Chart Studio Cloud for family . size sizesrc Sets the source reference on Chart Studio Cloud for size . Returns ------- Font """ super(Font, self).__init__("font") if "_parent" in kwargs: self._parent = kwargs["_parent"] return # Validate arg # ------------ if arg is None: arg = {} elif isinstance(arg, self.__class__): arg = arg.to_plotly_json() elif isinstance(arg, dict): arg = _copy.copy(arg) else: raise ValueError( """\ The first argument to the plotly.graph_objs.scattergl.hoverlabel.Font constructor must be a dict or an instance of :class:`plotly.graph_objs.scattergl.hoverlabel.Font`""" ) # Handle skip_invalid # ------------------- self._skip_invalid = kwargs.pop("skip_invalid", False) self._validate = kwargs.pop("_validate", True) # Populate data dict with properties # ---------------------------------- _v = arg.pop("color", None) _v = color if color is not None else _v if _v is not None: self["color"] = _v _v = arg.pop("colorsrc", None) _v = colorsrc if colorsrc is not None else _v if _v is not None: self["colorsrc"] = _v _v = arg.pop("family", None) _v = family if family is not None else _v if _v is not None: self["family"] = _v _v = arg.pop("familysrc", None) _v = familysrc if familysrc is not None else _v if _v is not None: self["familysrc"] = _v _v = arg.pop("size", None) _v = size if size is not None else _v if _v is not None: self["size"] = _v _v = arg.pop("sizesrc", None) _v = sizesrc if sizesrc is not None else _v if _v is not None: self["sizesrc"] = _v # Process unknown kwargs # ---------------------- self._process_kwargs(**dict(arg, **kwargs)) # Reset skip_invalid # ------------------ self._skip_invalid = False
[ "def", "__init__", "(", "self", ",", "arg", "=", "None", ",", "color", "=", "None", ",", "colorsrc", "=", "None", ",", "family", "=", "None", ",", "familysrc", "=", "None", ",", "size", "=", "None", ",", "sizesrc", "=", "None", ",", "*", "*", "kwargs", ")", ":", "super", "(", "Font", ",", "self", ")", ".", "__init__", "(", "\"font\"", ")", "if", "\"_parent\"", "in", "kwargs", ":", "self", ".", "_parent", "=", "kwargs", "[", "\"_parent\"", "]", "return", "# Validate arg", "# ------------", "if", "arg", "is", "None", ":", "arg", "=", "{", "}", "elif", "isinstance", "(", "arg", ",", "self", ".", "__class__", ")", ":", "arg", "=", "arg", ".", "to_plotly_json", "(", ")", "elif", "isinstance", "(", "arg", ",", "dict", ")", ":", "arg", "=", "_copy", ".", "copy", "(", "arg", ")", "else", ":", "raise", "ValueError", "(", "\"\"\"\\\nThe first argument to the plotly.graph_objs.scattergl.hoverlabel.Font \nconstructor must be a dict or \nan instance of :class:`plotly.graph_objs.scattergl.hoverlabel.Font`\"\"\"", ")", "# Handle skip_invalid", "# -------------------", "self", ".", "_skip_invalid", "=", "kwargs", ".", "pop", "(", "\"skip_invalid\"", ",", "False", ")", "self", ".", "_validate", "=", "kwargs", ".", "pop", "(", "\"_validate\"", ",", "True", ")", "# Populate data dict with properties", "# ----------------------------------", "_v", "=", "arg", ".", "pop", "(", "\"color\"", ",", "None", ")", "_v", "=", "color", "if", "color", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"color\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"colorsrc\"", ",", "None", ")", "_v", "=", "colorsrc", "if", "colorsrc", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"colorsrc\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"family\"", ",", "None", ")", "_v", "=", "family", "if", "family", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"family\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"familysrc\"", ",", "None", ")", "_v", "=", "familysrc", "if", "familysrc", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"familysrc\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"size\"", ",", "None", ")", "_v", "=", "size", "if", "size", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"size\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"sizesrc\"", ",", "None", ")", "_v", "=", "sizesrc", "if", "sizesrc", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"sizesrc\"", "]", "=", "_v", "# Process unknown kwargs", "# ----------------------", "self", ".", "_process_kwargs", "(", "*", "*", "dict", "(", "arg", ",", "*", "*", "kwargs", ")", ")", "# Reset skip_invalid", "# ------------------", "self", ".", "_skip_invalid", "=", "False" ]
[ 215, 4 ]
[ 329, 34 ]
python
en
['en', 'error', 'th']
False
Textfont.color
(self)
Sets the text font color of selected points. 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: aliceblue, antiquewhite, aqua, aquamarine, azure, beige, bisque, black, blanchedalmond, blue, blueviolet, brown, burlywood, cadetblue, chartreuse, chocolate, coral, cornflowerblue, cornsilk, crimson, cyan, darkblue, darkcyan, darkgoldenrod, darkgray, darkgrey, darkgreen, darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred, darksalmon, darkseagreen, darkslateblue, darkslategray, darkslategrey, darkturquoise, darkviolet, deeppink, deepskyblue, dimgray, dimgrey, dodgerblue, firebrick, floralwhite, forestgreen, fuchsia, gainsboro, ghostwhite, gold, goldenrod, gray, grey, green, greenyellow, honeydew, hotpink, indianred, indigo, ivory, khaki, lavender, lavenderblush, lawngreen, lemonchiffon, lightblue, lightcoral, lightcyan, lightgoldenrodyellow, lightgray, lightgrey, lightgreen, lightpink, lightsalmon, lightseagreen, lightskyblue, lightslategray, lightslategrey, lightsteelblue, lightyellow, lime, limegreen, linen, magenta, maroon, mediumaquamarine, mediumblue, mediumorchid, mediumpurple, mediumseagreen, mediumslateblue, mediumspringgreen, mediumturquoise, mediumvioletred, midnightblue, mintcream, mistyrose, moccasin, navajowhite, navy, oldlace, olive, olivedrab, orange, orangered, orchid, palegoldenrod, palegreen, paleturquoise, palevioletred, papayawhip, peachpuff, peru, pink, plum, powderblue, purple, red, rosybrown, royalblue, rebeccapurple, saddlebrown, salmon, sandybrown, seagreen, seashell, sienna, silver, skyblue, slateblue, slategray, slategrey, snow, springgreen, steelblue, tan, teal, thistle, tomato, turquoise, violet, wheat, white, whitesmoke, yellow, yellowgreen Returns ------- str
Sets the text font color of selected points. 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: aliceblue, antiquewhite, aqua, aquamarine, azure, beige, bisque, black, blanchedalmond, blue, blueviolet, brown, burlywood, cadetblue, chartreuse, chocolate, coral, cornflowerblue, cornsilk, crimson, cyan, darkblue, darkcyan, darkgoldenrod, darkgray, darkgrey, darkgreen, darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred, darksalmon, darkseagreen, darkslateblue, darkslategray, darkslategrey, darkturquoise, darkviolet, deeppink, deepskyblue, dimgray, dimgrey, dodgerblue, firebrick, floralwhite, forestgreen, fuchsia, gainsboro, ghostwhite, gold, goldenrod, gray, grey, green, greenyellow, honeydew, hotpink, indianred, indigo, ivory, khaki, lavender, lavenderblush, lawngreen, lemonchiffon, lightblue, lightcoral, lightcyan, lightgoldenrodyellow, lightgray, lightgrey, lightgreen, lightpink, lightsalmon, lightseagreen, lightskyblue, lightslategray, lightslategrey, lightsteelblue, lightyellow, lime, limegreen, linen, magenta, maroon, mediumaquamarine, mediumblue, mediumorchid, mediumpurple, mediumseagreen, mediumslateblue, mediumspringgreen, mediumturquoise, mediumvioletred, midnightblue, mintcream, mistyrose, moccasin, navajowhite, navy, oldlace, olive, olivedrab, orange, orangered, orchid, palegoldenrod, palegreen, paleturquoise, palevioletred, papayawhip, peachpuff, peru, pink, plum, powderblue, purple, red, rosybrown, royalblue, rebeccapurple, saddlebrown, salmon, sandybrown, seagreen, seashell, sienna, silver, skyblue, slateblue, slategray, slategrey, snow, springgreen, steelblue, tan, teal, thistle, tomato, turquoise, violet, wheat, white, whitesmoke, yellow, yellowgreen
def color(self): """ Sets the text font color of selected points. 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: aliceblue, antiquewhite, aqua, aquamarine, azure, beige, bisque, black, blanchedalmond, blue, blueviolet, brown, burlywood, cadetblue, chartreuse, chocolate, coral, cornflowerblue, cornsilk, crimson, cyan, darkblue, darkcyan, darkgoldenrod, darkgray, darkgrey, darkgreen, darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred, darksalmon, darkseagreen, darkslateblue, darkslategray, darkslategrey, darkturquoise, darkviolet, deeppink, deepskyblue, dimgray, dimgrey, dodgerblue, firebrick, floralwhite, forestgreen, fuchsia, gainsboro, ghostwhite, gold, goldenrod, gray, grey, green, greenyellow, honeydew, hotpink, indianred, indigo, ivory, khaki, lavender, lavenderblush, lawngreen, lemonchiffon, lightblue, lightcoral, lightcyan, lightgoldenrodyellow, lightgray, lightgrey, lightgreen, lightpink, lightsalmon, lightseagreen, lightskyblue, lightslategray, lightslategrey, lightsteelblue, lightyellow, lime, limegreen, linen, magenta, maroon, mediumaquamarine, mediumblue, mediumorchid, mediumpurple, mediumseagreen, mediumslateblue, mediumspringgreen, mediumturquoise, mediumvioletred, midnightblue, mintcream, mistyrose, moccasin, navajowhite, navy, oldlace, olive, olivedrab, orange, orangered, orchid, palegoldenrod, palegreen, paleturquoise, palevioletred, papayawhip, peachpuff, peru, pink, plum, powderblue, purple, red, rosybrown, royalblue, rebeccapurple, saddlebrown, salmon, sandybrown, seagreen, seashell, sienna, silver, skyblue, slateblue, slategray, slategrey, snow, springgreen, steelblue, tan, teal, thistle, tomato, turquoise, violet, wheat, white, whitesmoke, yellow, yellowgreen Returns ------- str """ return self["color"]
[ "def", "color", "(", "self", ")", ":", "return", "self", "[", "\"color\"", "]" ]
[ 15, 4 ]
[ 65, 28 ]
python
en
['en', 'error', 'th']
False
Textfont.__init__
(self, arg=None, color=None, **kwargs)
Construct a new Textfont object Parameters ---------- arg dict of properties compatible with this constructor or an instance of :class:`plotly.graph_objs.bar.selected.Textfont` color Sets the text font color of selected points. Returns ------- Textfont
Construct a new Textfont object Parameters ---------- arg dict of properties compatible with this constructor or an instance of :class:`plotly.graph_objs.bar.selected.Textfont` color Sets the text font color of selected points.
def __init__(self, arg=None, color=None, **kwargs): """ Construct a new Textfont object Parameters ---------- arg dict of properties compatible with this constructor or an instance of :class:`plotly.graph_objs.bar.selected.Textfont` color Sets the text font color of selected points. Returns ------- Textfont """ super(Textfont, self).__init__("textfont") if "_parent" in kwargs: self._parent = kwargs["_parent"] return # Validate arg # ------------ if arg is None: arg = {} elif isinstance(arg, self.__class__): arg = arg.to_plotly_json() elif isinstance(arg, dict): arg = _copy.copy(arg) else: raise ValueError( """\ The first argument to the plotly.graph_objs.bar.selected.Textfont constructor must be a dict or an instance of :class:`plotly.graph_objs.bar.selected.Textfont`""" ) # Handle skip_invalid # ------------------- self._skip_invalid = kwargs.pop("skip_invalid", False) self._validate = kwargs.pop("_validate", True) # Populate data dict with properties # ---------------------------------- _v = arg.pop("color", None) _v = color if color is not None else _v if _v is not None: self["color"] = _v # Process unknown kwargs # ---------------------- self._process_kwargs(**dict(arg, **kwargs)) # Reset skip_invalid # ------------------ self._skip_invalid = False
[ "def", "__init__", "(", "self", ",", "arg", "=", "None", ",", "color", "=", "None", ",", "*", "*", "kwargs", ")", ":", "super", "(", "Textfont", ",", "self", ")", ".", "__init__", "(", "\"textfont\"", ")", "if", "\"_parent\"", "in", "kwargs", ":", "self", ".", "_parent", "=", "kwargs", "[", "\"_parent\"", "]", "return", "# Validate arg", "# ------------", "if", "arg", "is", "None", ":", "arg", "=", "{", "}", "elif", "isinstance", "(", "arg", ",", "self", ".", "__class__", ")", ":", "arg", "=", "arg", ".", "to_plotly_json", "(", ")", "elif", "isinstance", "(", "arg", ",", "dict", ")", ":", "arg", "=", "_copy", ".", "copy", "(", "arg", ")", "else", ":", "raise", "ValueError", "(", "\"\"\"\\\nThe first argument to the plotly.graph_objs.bar.selected.Textfont \nconstructor must be a dict or \nan instance of :class:`plotly.graph_objs.bar.selected.Textfont`\"\"\"", ")", "# Handle skip_invalid", "# -------------------", "self", ".", "_skip_invalid", "=", "kwargs", ".", "pop", "(", "\"skip_invalid\"", ",", "False", ")", "self", ".", "_validate", "=", "kwargs", ".", "pop", "(", "\"_validate\"", ",", "True", ")", "# Populate data dict with properties", "# ----------------------------------", "_v", "=", "arg", ".", "pop", "(", "\"color\"", ",", "None", ")", "_v", "=", "color", "if", "color", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"color\"", "]", "=", "_v", "# Process unknown kwargs", "# ----------------------", "self", ".", "_process_kwargs", "(", "*", "*", "dict", "(", "arg", ",", "*", "*", "kwargs", ")", ")", "# Reset skip_invalid", "# ------------------", "self", ".", "_skip_invalid", "=", "False" ]
[ 80, 4 ]
[ 137, 34 ]
python
en
['en', 'error', 'th']
False
add_common_args
(parser)
Add arguments common across all of the datasets.
Add arguments common across all of the datasets.
def add_common_args(parser): """ Add arguments common across all of the datasets. """ agent = parser.add_argument_group('Gender Multiclass args') agent.add_argument( '--balance', type='bool', default=False, help='Whether to balance the data between classes during training', ) agent.add_argument( '--balance-valid', type='bool', default=False, help='Whether to balance the validation data', ) agent.add_argument( '--add-unknown-classes', type='bool', default=False, help='Add unknown classes as neutral', ) agent.add_argument( '--unknown-temp', type=float, default=1.0, help='Rate at which to sample examples from the unknown class', ) return parser
[ "def", "add_common_args", "(", "parser", ")", ":", "agent", "=", "parser", ".", "add_argument_group", "(", "'Gender Multiclass args'", ")", "agent", ".", "add_argument", "(", "'--balance'", ",", "type", "=", "'bool'", ",", "default", "=", "False", ",", "help", "=", "'Whether to balance the data between classes during training'", ",", ")", "agent", ".", "add_argument", "(", "'--balance-valid'", ",", "type", "=", "'bool'", ",", "default", "=", "False", ",", "help", "=", "'Whether to balance the validation data'", ",", ")", "agent", ".", "add_argument", "(", "'--add-unknown-classes'", ",", "type", "=", "'bool'", ",", "default", "=", "False", ",", "help", "=", "'Add unknown classes as neutral'", ",", ")", "agent", ".", "add_argument", "(", "'--unknown-temp'", ",", "type", "=", "float", ",", "default", "=", "1.0", ",", "help", "=", "'Rate at which to sample examples from the unknown class'", ",", ")", "return", "parser" ]
[ 67, 0 ]
[ 96, 17 ]
python
en
['en', 'error', 'th']
False
balance_data
(data_list, key='labels', shuffle=True, exclude_labels=None)
Given a list of acts, balance the list by label.
Given a list of acts, balance the list by label.
def balance_data(data_list, key='labels', shuffle=True, exclude_labels=None): """ Given a list of acts, balance the list by label. """ if len(data_list) == 0: # empty set return data_list def get_lst_sample(lst, sample_size): if len(lst) == sample_size: return lst sampled = [] sample_times = sample_size // len(lst) for _ in range(sample_times): sampled += lst differential = sample_size - len(sampled) if differential > 0: extra_examples = random.sample(lst, differential) sampled += extra_examples return sampled separate_data = {} excluded_data = [] for x in data_list: label = x[key] if isinstance(label, list): label = label[0] if exclude_labels is not None and label in exclude_labels: # exclude this from the balancing, but # add it later excluded_data.append(x) else: separate_data.setdefault(label, []) separate_data[label].append(x) max_len = max(len(value) for value in separate_data.values()) new_data = [] for _, data in separate_data.items(): exs = get_lst_sample(data, max_len) new_data += exs assert len(new_data) == max_len * len(separate_data) # now add back data that was excluded from balancing new_data += excluded_data if shuffle: random.shuffle(new_data) return new_data
[ "def", "balance_data", "(", "data_list", ",", "key", "=", "'labels'", ",", "shuffle", "=", "True", ",", "exclude_labels", "=", "None", ")", ":", "if", "len", "(", "data_list", ")", "==", "0", ":", "# empty set", "return", "data_list", "def", "get_lst_sample", "(", "lst", ",", "sample_size", ")", ":", "if", "len", "(", "lst", ")", "==", "sample_size", ":", "return", "lst", "sampled", "=", "[", "]", "sample_times", "=", "sample_size", "//", "len", "(", "lst", ")", "for", "_", "in", "range", "(", "sample_times", ")", ":", "sampled", "+=", "lst", "differential", "=", "sample_size", "-", "len", "(", "sampled", ")", "if", "differential", ">", "0", ":", "extra_examples", "=", "random", ".", "sample", "(", "lst", ",", "differential", ")", "sampled", "+=", "extra_examples", "return", "sampled", "separate_data", "=", "{", "}", "excluded_data", "=", "[", "]", "for", "x", "in", "data_list", ":", "label", "=", "x", "[", "key", "]", "if", "isinstance", "(", "label", ",", "list", ")", ":", "label", "=", "label", "[", "0", "]", "if", "exclude_labels", "is", "not", "None", "and", "label", "in", "exclude_labels", ":", "# exclude this from the balancing, but", "# add it later", "excluded_data", ".", "append", "(", "x", ")", "else", ":", "separate_data", ".", "setdefault", "(", "label", ",", "[", "]", ")", "separate_data", "[", "label", "]", ".", "append", "(", "x", ")", "max_len", "=", "max", "(", "len", "(", "value", ")", "for", "value", "in", "separate_data", ".", "values", "(", ")", ")", "new_data", "=", "[", "]", "for", "_", ",", "data", "in", "separate_data", ".", "items", "(", ")", ":", "exs", "=", "get_lst_sample", "(", "data", ",", "max_len", ")", "new_data", "+=", "exs", "assert", "len", "(", "new_data", ")", "==", "max_len", "*", "len", "(", "separate_data", ")", "# now add back data that was excluded from balancing", "new_data", "+=", "excluded_data", "if", "shuffle", ":", "random", ".", "shuffle", "(", "new_data", ")", "return", "new_data" ]
[ 99, 0 ]
[ 150, 19 ]
python
en
['en', 'error', 'th']
False
get_inferred_about_data
(task, opt, threshold=0.8)
Load inferred ABOUT data from teh ABOUT classifier.
Load inferred ABOUT data from teh ABOUT classifier.
def get_inferred_about_data(task, opt, threshold=0.8): """ Load inferred ABOUT data from teh ABOUT classifier. """ root = os.path.join( opt['datapath'], 'md_gender', 'data_to_release', 'inferred_about' ) task_str = task.split(':')[-1] dt = opt['datatype'].split(':')[0] with open(os.path.join(root, f'{task_str}_{dt}_binary.txt'), 'r') as f: lines = f.read().splitlines() examples = [] for line in lines: text, label, score = line.split('\t') if threshold is not None and float(score) < threshold: # replace label with NEUTRAL label = f'ABOUT:{NEUTRAL}' if not text or not label: continue examples.append( { 'text': text, 'labels': [label], 'class_type': 'about', 'label_candidates': ABOUT_CANDS, 'episode_done': True, } ) return examples
[ "def", "get_inferred_about_data", "(", "task", ",", "opt", ",", "threshold", "=", "0.8", ")", ":", "root", "=", "os", ".", "path", ".", "join", "(", "opt", "[", "'datapath'", "]", ",", "'md_gender'", ",", "'data_to_release'", ",", "'inferred_about'", ")", "task_str", "=", "task", ".", "split", "(", "':'", ")", "[", "-", "1", "]", "dt", "=", "opt", "[", "'datatype'", "]", ".", "split", "(", "':'", ")", "[", "0", "]", "with", "open", "(", "os", ".", "path", ".", "join", "(", "root", ",", "f'{task_str}_{dt}_binary.txt'", ")", ",", "'r'", ")", "as", "f", ":", "lines", "=", "f", ".", "read", "(", ")", ".", "splitlines", "(", ")", "examples", "=", "[", "]", "for", "line", "in", "lines", ":", "text", ",", "label", ",", "score", "=", "line", ".", "split", "(", "'\\t'", ")", "if", "threshold", "is", "not", "None", "and", "float", "(", "score", ")", "<", "threshold", ":", "# replace label with NEUTRAL", "label", "=", "f'ABOUT:{NEUTRAL}'", "if", "not", "text", "or", "not", "label", ":", "continue", "examples", ".", "append", "(", "{", "'text'", ":", "text", ",", "'labels'", ":", "[", "label", "]", ",", "'class_type'", ":", "'about'", ",", "'label_candidates'", ":", "ABOUT_CANDS", ",", "'episode_done'", ":", "True", ",", "}", ")", "return", "examples" ]
[ 153, 0 ]
[ 182, 19 ]
python
en
['en', 'error', 'th']
False
format_text
(text, lower=True)
Add spaces around punctuation.
Add spaces around punctuation.
def format_text(text, lower=True): """ Add spaces around punctuation. """ if lower: text = text.lower() for punc in PUNCTUATION_LST: text = text.replace(punc[1], punc[0]) return text
[ "def", "format_text", "(", "text", ",", "lower", "=", "True", ")", ":", "if", "lower", ":", "text", "=", "text", ".", "lower", "(", ")", "for", "punc", "in", "PUNCTUATION_LST", ":", "text", "=", "text", ".", "replace", "(", "punc", "[", "1", "]", ",", "punc", "[", "0", "]", ")", "return", "text" ]
[ 185, 0 ]
[ 194, 15 ]
python
en
['en', 'error', 'th']
False
unformat_text
(text)
Remove spaces from punctuation.
Remove spaces from punctuation.
def unformat_text(text): """ Remove spaces from punctuation. """ for punc in PUNCTUATION_LST: text = text.replace(punc[0], punc[1]) return text
[ "def", "unformat_text", "(", "text", ")", ":", "for", "punc", "in", "PUNCTUATION_LST", ":", "text", "=", "text", ".", "replace", "(", "punc", "[", "0", "]", ",", "punc", "[", "1", "]", ")", "return", "text" ]
[ 197, 0 ]
[ 204, 15 ]
python
en
['en', 'error', 'th']
False
get_explicitly_gendered_words
(opt)
Load list of explicitly gendered words from. <https://github.com/uclanlp/gn_glove/blob/master/wordlist/>. Examples include brother, girl, actress, husbands, etc.
Load list of explicitly gendered words from.
def get_explicitly_gendered_words(opt): """ Load list of explicitly gendered words from. <https://github.com/uclanlp/gn_glove/blob/master/wordlist/>. Examples include brother, girl, actress, husbands, etc. """ build(opt) folder = os.path.join(opt['datapath'], 'md_gender', 'data_to_release', 'word_list') male_words = os.path.join(folder, 'male_word_file.txt') female_words = os.path.join(folder, 'female_word_file.txt') with open(male_words, 'r') as f: male = f.read().splitlines() with open(female_words, 'r') as f: female = f.read().splitlines() return male, female
[ "def", "get_explicitly_gendered_words", "(", "opt", ")", ":", "build", "(", "opt", ")", "folder", "=", "os", ".", "path", ".", "join", "(", "opt", "[", "'datapath'", "]", ",", "'md_gender'", ",", "'data_to_release'", ",", "'word_list'", ")", "male_words", "=", "os", ".", "path", ".", "join", "(", "folder", ",", "'male_word_file.txt'", ")", "female_words", "=", "os", ".", "path", ".", "join", "(", "folder", ",", "'female_word_file.txt'", ")", "with", "open", "(", "male_words", ",", "'r'", ")", "as", "f", ":", "male", "=", "f", ".", "read", "(", ")", ".", "splitlines", "(", ")", "with", "open", "(", "female_words", ",", "'r'", ")", "as", "f", ":", "female", "=", "f", ".", "read", "(", ")", ".", "splitlines", "(", ")", "return", "male", ",", "female" ]
[ 207, 0 ]
[ 226, 23 ]
python
en
['en', 'error', 'th']
False
mask_gendered_words
(text, gendered_list, mask_token=MASK_TOKEN)
Given a string of text, mask out gendered words from a list.
Given a string of text, mask out gendered words from a list.
def mask_gendered_words(text, gendered_list, mask_token=MASK_TOKEN): """ Given a string of text, mask out gendered words from a list. """ text = format_text(text, lower=False) to_ret = [] orig_text = text.split(' ') lowered_text = text.lower().split(' ') for word, word_lower in zip(orig_text, lowered_text): if word_lower in gendered_list: to_ret.append(mask_token) else: to_ret.append(word) return unformat_text(' '.join(to_ret))
[ "def", "mask_gendered_words", "(", "text", ",", "gendered_list", ",", "mask_token", "=", "MASK_TOKEN", ")", ":", "text", "=", "format_text", "(", "text", ",", "lower", "=", "False", ")", "to_ret", "=", "[", "]", "orig_text", "=", "text", ".", "split", "(", "' '", ")", "lowered_text", "=", "text", ".", "lower", "(", ")", ".", "split", "(", "' '", ")", "for", "word", ",", "word_lower", "in", "zip", "(", "orig_text", ",", "lowered_text", ")", ":", "if", "word_lower", "in", "gendered_list", ":", "to_ret", ".", "append", "(", "mask_token", ")", "else", ":", "to_ret", ".", "append", "(", "word", ")", "return", "unformat_text", "(", "' '", ".", "join", "(", "to_ret", ")", ")" ]
[ 229, 0 ]
[ 243, 42 ]
python
en
['en', 'error', 'th']
False
init_tree_selection
(treestr, caller, callback, index=None, mark_category=True, go_back=True, cmd_on_exit="look", start_text="Make your selection:")
Prompts a player to select an option from a menu tree given as a multi-line string. Args: treestr (str): Multi-lne string representing menu options caller (obj): Player to initialize the menu for callback (callable): Function to run when a selection is made. Must take 4 args: caller (obj): Caller given above treestr (str): Menu tree string given above index (int): Index of final selection selection (str): Key of final selection Options: index (int or None): Index to start the menu at, or None for top level mark_category (bool): If True, marks categories with a [+] symbol in the menu go_back (bool): If True, present an option to go back to previous categories start_text (str): Text to display at the top level of the menu cmd_on_exit(str): Command to enter when the menu exits - 'look' by default Notes: This function will initialize an instance of EvMenu with options generated dynamically from the source string, and passes the menu user's selection to a function of your choosing. The EvMenu is made of a single, repeating node, which will call itself over and over at different levels of the menu tree as categories are selected. Once a non-category selection is made, the user's selection will be passed to the given callable, both as a string and as an index number. The index is given to ensure every selection has a unique identifier, so that selections with the same key in different categories can be distinguished between. The menus called by this function are not persistent and cannot perform complicated tasks like prompt for arbitrary input or jump multiple category levels at once - you'll have to use EvMenu itself if you want to take full advantage of its features.
Prompts a player to select an option from a menu tree given as a multi-line string.
def init_tree_selection(treestr, caller, callback, index=None, mark_category=True, go_back=True, cmd_on_exit="look", start_text="Make your selection:"): """ Prompts a player to select an option from a menu tree given as a multi-line string. Args: treestr (str): Multi-lne string representing menu options caller (obj): Player to initialize the menu for callback (callable): Function to run when a selection is made. Must take 4 args: caller (obj): Caller given above treestr (str): Menu tree string given above index (int): Index of final selection selection (str): Key of final selection Options: index (int or None): Index to start the menu at, or None for top level mark_category (bool): If True, marks categories with a [+] symbol in the menu go_back (bool): If True, present an option to go back to previous categories start_text (str): Text to display at the top level of the menu cmd_on_exit(str): Command to enter when the menu exits - 'look' by default Notes: This function will initialize an instance of EvMenu with options generated dynamically from the source string, and passes the menu user's selection to a function of your choosing. The EvMenu is made of a single, repeating node, which will call itself over and over at different levels of the menu tree as categories are selected. Once a non-category selection is made, the user's selection will be passed to the given callable, both as a string and as an index number. The index is given to ensure every selection has a unique identifier, so that selections with the same key in different categories can be distinguished between. The menus called by this function are not persistent and cannot perform complicated tasks like prompt for arbitrary input or jump multiple category levels at once - you'll have to use EvMenu itself if you want to take full advantage of its features. """ # Pass kwargs to store data needed in the menu kwargs = { "index":index, "mark_category":mark_category, "go_back":go_back, "treestr":treestr, "callback":callback, "start_text":start_text } # Initialize menu of selections evmenu.EvMenu(caller, "evennia.contrib.tree_select", startnode="menunode_treeselect", startnode_input=None, cmd_on_exit=cmd_on_exit, **kwargs)
[ "def", "init_tree_selection", "(", "treestr", ",", "caller", ",", "callback", ",", "index", "=", "None", ",", "mark_category", "=", "True", ",", "go_back", "=", "True", ",", "cmd_on_exit", "=", "\"look\"", ",", "start_text", "=", "\"Make your selection:\"", ")", ":", "# Pass kwargs to store data needed in the menu", "kwargs", "=", "{", "\"index\"", ":", "index", ",", "\"mark_category\"", ":", "mark_category", ",", "\"go_back\"", ":", "go_back", ",", "\"treestr\"", ":", "treestr", ",", "\"callback\"", ":", "callback", ",", "\"start_text\"", ":", "start_text", "}", "# Initialize menu of selections", "evmenu", ".", "EvMenu", "(", "caller", ",", "\"evennia.contrib.tree_select\"", ",", "startnode", "=", "\"menunode_treeselect\"", ",", "startnode_input", "=", "None", ",", "cmd_on_exit", "=", "cmd_on_exit", ",", "*", "*", "kwargs", ")" ]
[ 163, 0 ]
[ 217, 74 ]
python
en
['en', 'error', 'th']
False
dashcount
(entry)
Counts the number of dashes at the beginning of a string. This is needed to determine the depth of options in categories. Args: entry (str): String to count the dashes at the start of Returns: dashes (int): Number of dashes at the start
Counts the number of dashes at the beginning of a string. This is needed to determine the depth of options in categories.
def dashcount(entry): """ Counts the number of dashes at the beginning of a string. This is needed to determine the depth of options in categories. Args: entry (str): String to count the dashes at the start of Returns: dashes (int): Number of dashes at the start """ dashes = 0 for char in entry: if char == "-": dashes += 1 else: return dashes return dashes
[ "def", "dashcount", "(", "entry", ")", ":", "dashes", "=", "0", "for", "char", "in", "entry", ":", "if", "char", "==", "\"-\"", ":", "dashes", "+=", "1", "else", ":", "return", "dashes", "return", "dashes" ]
[ 219, 0 ]
[ 236, 17 ]
python
en
['en', 'error', 'th']
False
is_category
(treestr, index)
Determines whether an option in a tree string is a category by whether or not there are additional options below it. Args: treestr (str): Multi-line string representing menu options index (int): Which line of the string to test Returns: is_category (bool): Whether the option is a category
Determines whether an option in a tree string is a category by whether or not there are additional options below it.
def is_category(treestr, index): """ Determines whether an option in a tree string is a category by whether or not there are additional options below it. Args: treestr (str): Multi-line string representing menu options index (int): Which line of the string to test Returns: is_category (bool): Whether the option is a category """ opt_list = treestr.split('\n') # Not a category if it's the last one in the list if index == len(opt_list) - 1: return False # Not a category if next option is not one level deeper return not bool(dashcount(opt_list[index+1]) != dashcount(opt_list[index]) + 1)
[ "def", "is_category", "(", "treestr", ",", "index", ")", ":", "opt_list", "=", "treestr", ".", "split", "(", "'\\n'", ")", "# Not a category if it's the last one in the list", "if", "index", "==", "len", "(", "opt_list", ")", "-", "1", ":", "return", "False", "# Not a category if next option is not one level deeper", "return", "not", "bool", "(", "dashcount", "(", "opt_list", "[", "index", "+", "1", "]", ")", "!=", "dashcount", "(", "opt_list", "[", "index", "]", ")", "+", "1", ")" ]
[ 238, 0 ]
[ 255, 83 ]
python
en
['en', 'error', 'th']
False
parse_opts
(treestr, category_index=None)
Parses a tree string and given index into a list of options. If category_index is none, returns all the options at the top level of the menu. If category_index corresponds to a category, returns a list of options under that category. If category_index corresponds to an option that is not a category, it's a selection and returns True. Args: treestr (str): Multi-line string representing menu options category_index (int): Index of category or None for top level Returns: kept_opts (list or True): Either a list of options in the selected category or True if a selection was made
Parses a tree string and given index into a list of options. If category_index is none, returns all the options at the top level of the menu. If category_index corresponds to a category, returns a list of options under that category. If category_index corresponds to an option that is not a category, it's a selection and returns True.
def parse_opts(treestr, category_index=None): """ Parses a tree string and given index into a list of options. If category_index is none, returns all the options at the top level of the menu. If category_index corresponds to a category, returns a list of options under that category. If category_index corresponds to an option that is not a category, it's a selection and returns True. Args: treestr (str): Multi-line string representing menu options category_index (int): Index of category or None for top level Returns: kept_opts (list or True): Either a list of options in the selected category or True if a selection was made """ dash_depth = 0 opt_list = treestr.split('\n') kept_opts = [] # If a category index is given if category_index != None: # If given index is not a category, it's a selection - return True. if not is_category(treestr, category_index): return True # Otherwise, change the dash depth to match the new category. dash_depth = dashcount(opt_list[category_index]) + 1 # Delete everything before the category index opt_list = opt_list [category_index+1:] # Keep every option (referenced by index) at the appropriate depth cur_index = 0 for option in opt_list: if dashcount(option) == dash_depth: if category_index == None: kept_opts.append((cur_index, option[dash_depth:])) else: kept_opts.append((cur_index + category_index + 1, option[dash_depth:])) # Exits the loop if leaving a category if dashcount(option) < dash_depth: return kept_opts cur_index += 1 return kept_opts
[ "def", "parse_opts", "(", "treestr", ",", "category_index", "=", "None", ")", ":", "dash_depth", "=", "0", "opt_list", "=", "treestr", ".", "split", "(", "'\\n'", ")", "kept_opts", "=", "[", "]", "# If a category index is given", "if", "category_index", "!=", "None", ":", "# If given index is not a category, it's a selection - return True.", "if", "not", "is_category", "(", "treestr", ",", "category_index", ")", ":", "return", "True", "# Otherwise, change the dash depth to match the new category.", "dash_depth", "=", "dashcount", "(", "opt_list", "[", "category_index", "]", ")", "+", "1", "# Delete everything before the category index", "opt_list", "=", "opt_list", "[", "category_index", "+", "1", ":", "]", "# Keep every option (referenced by index) at the appropriate depth", "cur_index", "=", "0", "for", "option", "in", "opt_list", ":", "if", "dashcount", "(", "option", ")", "==", "dash_depth", ":", "if", "category_index", "==", "None", ":", "kept_opts", ".", "append", "(", "(", "cur_index", ",", "option", "[", "dash_depth", ":", "]", ")", ")", "else", ":", "kept_opts", ".", "append", "(", "(", "cur_index", "+", "category_index", "+", "1", ",", "option", "[", "dash_depth", ":", "]", ")", ")", "# Exits the loop if leaving a category", "if", "dashcount", "(", "option", ")", "<", "dash_depth", ":", "return", "kept_opts", "cur_index", "+=", "1", "return", "kept_opts" ]
[ 257, 0 ]
[ 299, 20 ]
python
en
['en', 'error', 'th']
False
index_to_selection
(treestr, index, desc=False)
Given a menu tree string and an index, returns the corresponding selection's name as a string. If 'desc' is set to True, will return the selection's description as a string instead. Args: treestr (str): Multi-line string representing menu options index (int): Index to convert to selection key or description Options: desc (bool): If true, returns description instead of key Returns: selection (str): Selection key or description if 'desc' is set
Given a menu tree string and an index, returns the corresponding selection's name as a string. If 'desc' is set to True, will return the selection's description as a string instead.
def index_to_selection(treestr, index, desc=False): """ Given a menu tree string and an index, returns the corresponding selection's name as a string. If 'desc' is set to True, will return the selection's description as a string instead. Args: treestr (str): Multi-line string representing menu options index (int): Index to convert to selection key or description Options: desc (bool): If true, returns description instead of key Returns: selection (str): Selection key or description if 'desc' is set """ opt_list = treestr.split('\n') # Fetch the given line selection = opt_list[index] # Strip out the dashes at the start selection = selection[dashcount(selection):] # Separate out description, if any if ":" in selection: # Split string into key and description selection = selection.split(':', 1) selection[1] = selection[1].strip(" ") else: # If no description given, set description to None selection = [selection, None] if not desc: return selection[0] else: return selection[1]
[ "def", "index_to_selection", "(", "treestr", ",", "index", ",", "desc", "=", "False", ")", ":", "opt_list", "=", "treestr", ".", "split", "(", "'\\n'", ")", "# Fetch the given line", "selection", "=", "opt_list", "[", "index", "]", "# Strip out the dashes at the start", "selection", "=", "selection", "[", "dashcount", "(", "selection", ")", ":", "]", "# Separate out description, if any", "if", "\":\"", "in", "selection", ":", "# Split string into key and description", "selection", "=", "selection", ".", "split", "(", "':'", ",", "1", ")", "selection", "[", "1", "]", "=", "selection", "[", "1", "]", ".", "strip", "(", "\" \"", ")", "else", ":", "# If no description given, set description to None", "selection", "=", "[", "selection", ",", "None", "]", "if", "not", "desc", ":", "return", "selection", "[", "0", "]", "else", ":", "return", "selection", "[", "1", "]" ]
[ 301, 0 ]
[ 333, 27 ]
python
en
['en', 'error', 'th']
False
go_up_one_category
(treestr, index)
Given a menu tree string and an index, returns the category that the given option belongs to. Used for the 'go back' option. Args: treestr (str): Multi-line string representing menu options index (int): Index to determine the parent category of Returns: parent_category (int): Index of parent category
Given a menu tree string and an index, returns the category that the given option belongs to. Used for the 'go back' option.
def go_up_one_category(treestr, index): """ Given a menu tree string and an index, returns the category that the given option belongs to. Used for the 'go back' option. Args: treestr (str): Multi-line string representing menu options index (int): Index to determine the parent category of Returns: parent_category (int): Index of parent category """ opt_list = treestr.split('\n') # Get the number of dashes deep the given index is dash_level = dashcount(opt_list[index]) # Delete everything after the current index opt_list = opt_list[:index+1] # If there's no dash, return 'None' to return to base menu if dash_level == 0: return None current_index = index # Go up through each option until we find one that's one category above for selection in reversed(opt_list): if dashcount(selection) == dash_level - 1: return current_index current_index -= 1
[ "def", "go_up_one_category", "(", "treestr", ",", "index", ")", ":", "opt_list", "=", "treestr", ".", "split", "(", "'\\n'", ")", "# Get the number of dashes deep the given index is", "dash_level", "=", "dashcount", "(", "opt_list", "[", "index", "]", ")", "# Delete everything after the current index", "opt_list", "=", "opt_list", "[", ":", "index", "+", "1", "]", "# If there's no dash, return 'None' to return to base menu", "if", "dash_level", "==", "0", ":", "return", "None", "current_index", "=", "index", "# Go up through each option until we find one that's one category above", "for", "selection", "in", "reversed", "(", "opt_list", ")", ":", "if", "dashcount", "(", "selection", ")", "==", "dash_level", "-", "1", ":", "return", "current_index", "current_index", "-=", "1" ]
[ 335, 0 ]
[ 362, 26 ]
python
en
['en', 'error', 'th']
False
optlist_to_menuoptions
(treestr, optlist, index, mark_category, go_back)
Takes a list of options processed by parse_opts and turns it into a list/dictionary of menu options for use in menunode_treeselect. Args: treestr (str): Multi-line string representing menu options optlist (list): List of options to convert to EvMenu's option format index (int): Index of current category mark_category (bool): Whether or not to mark categories with [+] go_back (bool): Whether or not to add an option to go back in the menu Returns: menuoptions (list of dicts): List of menu options formatted for use in EvMenu, each passing a different "newindex" kwarg that changes the menu level or makes a selection
Takes a list of options processed by parse_opts and turns it into a list/dictionary of menu options for use in menunode_treeselect.
def optlist_to_menuoptions(treestr, optlist, index, mark_category, go_back): """ Takes a list of options processed by parse_opts and turns it into a list/dictionary of menu options for use in menunode_treeselect. Args: treestr (str): Multi-line string representing menu options optlist (list): List of options to convert to EvMenu's option format index (int): Index of current category mark_category (bool): Whether or not to mark categories with [+] go_back (bool): Whether or not to add an option to go back in the menu Returns: menuoptions (list of dicts): List of menu options formatted for use in EvMenu, each passing a different "newindex" kwarg that changes the menu level or makes a selection """ menuoptions = [] cur_index = 0 for option in optlist: index_to_add = optlist[cur_index][0] menuitem = {} keystr = index_to_selection(treestr, index_to_add) if mark_category and is_category(treestr, index_to_add): # Add the [+] to the key if marking categories, and the key by itself as an alias menuitem["key"] = [keystr + " [+]", keystr] else: menuitem["key"] = keystr # Get the option's description desc = index_to_selection(treestr, index_to_add, desc=True) if desc: menuitem["desc"] = desc # Passing 'newindex' as a kwarg to the node is how we move through the menu! menuitem["goto"] = ["menunode_treeselect", {"newindex":index_to_add}] menuoptions.append(menuitem) cur_index += 1 # Add option to go back, if needed if index != None and go_back == True: gobackitem = {"key":["<< Go Back", "go back", "back"], "desc":"Return to the previous menu.", "goto":["menunode_treeselect", {"newindex":go_up_one_category(treestr, index)}]} menuoptions.append(gobackitem) return menuoptions
[ "def", "optlist_to_menuoptions", "(", "treestr", ",", "optlist", ",", "index", ",", "mark_category", ",", "go_back", ")", ":", "menuoptions", "=", "[", "]", "cur_index", "=", "0", "for", "option", "in", "optlist", ":", "index_to_add", "=", "optlist", "[", "cur_index", "]", "[", "0", "]", "menuitem", "=", "{", "}", "keystr", "=", "index_to_selection", "(", "treestr", ",", "index_to_add", ")", "if", "mark_category", "and", "is_category", "(", "treestr", ",", "index_to_add", ")", ":", "# Add the [+] to the key if marking categories, and the key by itself as an alias", "menuitem", "[", "\"key\"", "]", "=", "[", "keystr", "+", "\" [+]\"", ",", "keystr", "]", "else", ":", "menuitem", "[", "\"key\"", "]", "=", "keystr", "# Get the option's description", "desc", "=", "index_to_selection", "(", "treestr", ",", "index_to_add", ",", "desc", "=", "True", ")", "if", "desc", ":", "menuitem", "[", "\"desc\"", "]", "=", "desc", "# Passing 'newindex' as a kwarg to the node is how we move through the menu!", "menuitem", "[", "\"goto\"", "]", "=", "[", "\"menunode_treeselect\"", ",", "{", "\"newindex\"", ":", "index_to_add", "}", "]", "menuoptions", ".", "append", "(", "menuitem", ")", "cur_index", "+=", "1", "# Add option to go back, if needed", "if", "index", "!=", "None", "and", "go_back", "==", "True", ":", "gobackitem", "=", "{", "\"key\"", ":", "[", "\"<< Go Back\"", ",", "\"go back\"", ",", "\"back\"", "]", ",", "\"desc\"", ":", "\"Return to the previous menu.\"", ",", "\"goto\"", ":", "[", "\"menunode_treeselect\"", ",", "{", "\"newindex\"", ":", "go_up_one_category", "(", "treestr", ",", "index", ")", "}", "]", "}", "menuoptions", ".", "append", "(", "gobackitem", ")", "return", "menuoptions" ]
[ 364, 0 ]
[ 407, 22 ]
python
en
['en', 'error', 'th']
False
menunode_treeselect
(caller, raw_string, **kwargs)
This is the repeating menu node that handles the tree selection.
This is the repeating menu node that handles the tree selection.
def menunode_treeselect(caller, raw_string, **kwargs): """ This is the repeating menu node that handles the tree selection. """ # If 'newindex' is in the kwargs, change the stored index. if "newindex" in kwargs: caller.ndb._menutree.index = kwargs["newindex"] # Retrieve menu info index = caller.ndb._menutree.index mark_category = caller.ndb._menutree.mark_category go_back = caller.ndb._menutree.go_back treestr = caller.ndb._menutree.treestr callback = caller.ndb._menutree.callback start_text = caller.ndb._menutree.start_text # List of options if index is 'None' or category, or 'True' if a selection optlist = parse_opts(treestr, category_index=index) # If given index returns optlist as 'True', it's a selection. Pass to callback and end the menu. if optlist == True: selection = index_to_selection(treestr, index) try: callback(caller, treestr, index, selection) except Exception: log_trace("Error in tree selection callback.") # Returning None, None ends the menu. return None, None # Otherwise, convert optlist to a list of menu options. else: options = optlist_to_menuoptions(treestr, optlist, index, mark_category, go_back) if index == None: # Use start_text for the menu text on the top level text = start_text else: # Use the category name and description (if any) as the menu text if index_to_selection(treestr, index, desc=True) != None: text = "|w" + index_to_selection(treestr, index) + "|n: " + index_to_selection(treestr, index, desc=True) else: text = "|w" + index_to_selection(treestr, index) + "|n" return text, options
[ "def", "menunode_treeselect", "(", "caller", ",", "raw_string", ",", "*", "*", "kwargs", ")", ":", "# If 'newindex' is in the kwargs, change the stored index.", "if", "\"newindex\"", "in", "kwargs", ":", "caller", ".", "ndb", ".", "_menutree", ".", "index", "=", "kwargs", "[", "\"newindex\"", "]", "# Retrieve menu info", "index", "=", "caller", ".", "ndb", ".", "_menutree", ".", "index", "mark_category", "=", "caller", ".", "ndb", ".", "_menutree", ".", "mark_category", "go_back", "=", "caller", ".", "ndb", ".", "_menutree", ".", "go_back", "treestr", "=", "caller", ".", "ndb", ".", "_menutree", ".", "treestr", "callback", "=", "caller", ".", "ndb", ".", "_menutree", ".", "callback", "start_text", "=", "caller", ".", "ndb", ".", "_menutree", ".", "start_text", "# List of options if index is 'None' or category, or 'True' if a selection", "optlist", "=", "parse_opts", "(", "treestr", ",", "category_index", "=", "index", ")", "# If given index returns optlist as 'True', it's a selection. Pass to callback and end the menu.", "if", "optlist", "==", "True", ":", "selection", "=", "index_to_selection", "(", "treestr", ",", "index", ")", "try", ":", "callback", "(", "caller", ",", "treestr", ",", "index", ",", "selection", ")", "except", "Exception", ":", "log_trace", "(", "\"Error in tree selection callback.\"", ")", "# Returning None, None ends the menu.", "return", "None", ",", "None", "# Otherwise, convert optlist to a list of menu options.", "else", ":", "options", "=", "optlist_to_menuoptions", "(", "treestr", ",", "optlist", ",", "index", ",", "mark_category", ",", "go_back", ")", "if", "index", "==", "None", ":", "# Use start_text for the menu text on the top level", "text", "=", "start_text", "else", ":", "# Use the category name and description (if any) as the menu text", "if", "index_to_selection", "(", "treestr", ",", "index", ",", "desc", "=", "True", ")", "!=", "None", ":", "text", "=", "\"|w\"", "+", "index_to_selection", "(", "treestr", ",", "index", ")", "+", "\"|n: \"", "+", "index_to_selection", "(", "treestr", ",", "index", ",", "desc", "=", "True", ")", "else", ":", "text", "=", "\"|w\"", "+", "index_to_selection", "(", "treestr", ",", "index", ")", "+", "\"|n\"", "return", "text", ",", "options" ]
[ 409, 0 ]
[ 452, 28 ]
python
en
['en', 'error', 'th']
False
change_name_color
(caller, treestr, index, selection)
Changes a player's name color. Args: caller (obj): Character whose name to color. treestr (str): String for the color change menu - unused index (int): Index of menu selection - unused selection (str): Selection made from the name color menu - used to determine the color the player chose.
Changes a player's name color.
def change_name_color(caller, treestr, index, selection): """ Changes a player's name color. Args: caller (obj): Character whose name to color. treestr (str): String for the color change menu - unused index (int): Index of menu selection - unused selection (str): Selection made from the name color menu - used to determine the color the player chose. """ # Store the caller's uncolored name if not caller.db.uncolored_name: caller.db.uncolored_name = caller.key # Dictionary matching color selection names to color codes colordict = { "Red":"|511", "Pink":"|533", "Maroon":"|301", "Orange":"|531", "Brown":"|321", "Sienna":"|420", "Yellow":"|551", "Gold":"|540", "Dandelion":"|553", "Green":"|141", "Lime":"|350", "Forest":"|032", "Blue":"|115", "Cyan":"|155", "Navy":"|113", "Purple":"|415", "Lavender":"|535", "Fuchsia":"|503"} # I know this probably isn't the best way to do this. It's just an example! if selection == "Remove name color": # Player chose to remove their name color caller.key = caller.db.uncolored_name caller.msg("Name color removed.") elif selection in colordict: newcolor = colordict[selection] # Retrieve color code based on menu selection caller.key = newcolor + caller.db.uncolored_name + "|n" # Add color code to caller's name caller.msg(newcolor + ("Name color changed to %s!" % selection) + "|n")
[ "def", "change_name_color", "(", "caller", ",", "treestr", ",", "index", ",", "selection", ")", ":", "# Store the caller's uncolored name", "if", "not", "caller", ".", "db", ".", "uncolored_name", ":", "caller", ".", "db", ".", "uncolored_name", "=", "caller", ".", "key", "# Dictionary matching color selection names to color codes", "colordict", "=", "{", "\"Red\"", ":", "\"|511\"", ",", "\"Pink\"", ":", "\"|533\"", ",", "\"Maroon\"", ":", "\"|301\"", ",", "\"Orange\"", ":", "\"|531\"", ",", "\"Brown\"", ":", "\"|321\"", ",", "\"Sienna\"", ":", "\"|420\"", ",", "\"Yellow\"", ":", "\"|551\"", ",", "\"Gold\"", ":", "\"|540\"", ",", "\"Dandelion\"", ":", "\"|553\"", ",", "\"Green\"", ":", "\"|141\"", ",", "\"Lime\"", ":", "\"|350\"", ",", "\"Forest\"", ":", "\"|032\"", ",", "\"Blue\"", ":", "\"|115\"", ",", "\"Cyan\"", ":", "\"|155\"", ",", "\"Navy\"", ":", "\"|113\"", ",", "\"Purple\"", ":", "\"|415\"", ",", "\"Lavender\"", ":", "\"|535\"", ",", "\"Fuchsia\"", ":", "\"|503\"", "}", "# I know this probably isn't the best way to do this. It's just an example!", "if", "selection", "==", "\"Remove name color\"", ":", "# Player chose to remove their name color", "caller", ".", "key", "=", "caller", ".", "db", ".", "uncolored_name", "caller", ".", "msg", "(", "\"Name color removed.\"", ")", "elif", "selection", "in", "colordict", ":", "newcolor", "=", "colordict", "[", "selection", "]", "# Retrieve color code based on menu selection", "caller", ".", "key", "=", "newcolor", "+", "caller", ".", "db", ".", "uncolored_name", "+", "\"|n\"", "# Add color code to caller's name", "caller", ".", "msg", "(", "newcolor", "+", "(", "\"Name color changed to %s!\"", "%", "selection", ")", "+", "\"|n\"", ")" ]
[ 502, 0 ]
[ 533, 79 ]
python
en
['en', 'error', 'th']
False
Unselected.marker
(self)
The 'marker' property is an instance of Marker that may be specified as: - An instance of :class:`plotly.graph_objs.scatter.unselected.Marker` - A dict of string/value properties that will be passed to the Marker constructor Supported dict properties: color Sets the marker color of unselected points, applied only when a selection exists. opacity Sets the marker opacity of unselected points, applied only when a selection exists. size Sets the marker size of unselected points, applied only when a selection exists. Returns ------- plotly.graph_objs.scatter.unselected.Marker
The 'marker' property is an instance of Marker that may be specified as: - An instance of :class:`plotly.graph_objs.scatter.unselected.Marker` - A dict of string/value properties that will be passed to the Marker constructor Supported dict properties: color Sets the marker color of unselected points, applied only when a selection exists. opacity Sets the marker opacity of unselected points, applied only when a selection exists. size Sets the marker size of unselected points, applied only when a selection exists.
def marker(self): """ The 'marker' property is an instance of Marker that may be specified as: - An instance of :class:`plotly.graph_objs.scatter.unselected.Marker` - A dict of string/value properties that will be passed to the Marker constructor Supported dict properties: color Sets the marker color of unselected points, applied only when a selection exists. opacity Sets the marker opacity of unselected points, applied only when a selection exists. size Sets the marker size of unselected points, applied only when a selection exists. Returns ------- plotly.graph_objs.scatter.unselected.Marker """ return self["marker"]
[ "def", "marker", "(", "self", ")", ":", "return", "self", "[", "\"marker\"", "]" ]
[ 15, 4 ]
[ 39, 29 ]
python
en
['en', 'error', 'th']
False
Unselected.textfont
(self)
The 'textfont' property is an instance of Textfont that may be specified as: - An instance of :class:`plotly.graph_objs.scatter.unselected.Textfont` - A dict of string/value properties that will be passed to the Textfont constructor Supported dict properties: color Sets the text font color of unselected points, applied only when a selection exists. Returns ------- plotly.graph_objs.scatter.unselected.Textfont
The 'textfont' property is an instance of Textfont that may be specified as: - An instance of :class:`plotly.graph_objs.scatter.unselected.Textfont` - A dict of string/value properties that will be passed to the Textfont constructor Supported dict properties: color Sets the text font color of unselected points, applied only when a selection exists.
def textfont(self): """ The 'textfont' property is an instance of Textfont that may be specified as: - An instance of :class:`plotly.graph_objs.scatter.unselected.Textfont` - A dict of string/value properties that will be passed to the Textfont constructor Supported dict properties: color Sets the text font color of unselected points, applied only when a selection exists. Returns ------- plotly.graph_objs.scatter.unselected.Textfont """ return self["textfont"]
[ "def", "textfont", "(", "self", ")", ":", "return", "self", "[", "\"textfont\"", "]" ]
[ 48, 4 ]
[ 66, 31 ]
python
en
['en', 'error', 'th']
False
Unselected.__init__
(self, arg=None, marker=None, textfont=None, **kwargs)
Construct a new Unselected object Parameters ---------- arg dict of properties compatible with this constructor or an instance of :class:`plotly.graph_objs.scatter.Unselected` marker :class:`plotly.graph_objects.scatter.unselected.Marker` instance or dict with compatible properties textfont :class:`plotly.graph_objects.scatter.unselected.Textfon t` instance or dict with compatible properties Returns ------- Unselected
Construct a new Unselected object Parameters ---------- arg dict of properties compatible with this constructor or an instance of :class:`plotly.graph_objs.scatter.Unselected` marker :class:`plotly.graph_objects.scatter.unselected.Marker` instance or dict with compatible properties textfont :class:`plotly.graph_objects.scatter.unselected.Textfon t` instance or dict with compatible properties
def __init__(self, arg=None, marker=None, textfont=None, **kwargs): """ Construct a new Unselected object Parameters ---------- arg dict of properties compatible with this constructor or an instance of :class:`plotly.graph_objs.scatter.Unselected` marker :class:`plotly.graph_objects.scatter.unselected.Marker` instance or dict with compatible properties textfont :class:`plotly.graph_objects.scatter.unselected.Textfon t` instance or dict with compatible properties Returns ------- Unselected """ super(Unselected, self).__init__("unselected") if "_parent" in kwargs: self._parent = kwargs["_parent"] return # Validate arg # ------------ if arg is None: arg = {} elif isinstance(arg, self.__class__): arg = arg.to_plotly_json() elif isinstance(arg, dict): arg = _copy.copy(arg) else: raise ValueError( """\ The first argument to the plotly.graph_objs.scatter.Unselected constructor must be a dict or an instance of :class:`plotly.graph_objs.scatter.Unselected`""" ) # Handle skip_invalid # ------------------- self._skip_invalid = kwargs.pop("skip_invalid", False) self._validate = kwargs.pop("_validate", True) # Populate data dict with properties # ---------------------------------- _v = arg.pop("marker", None) _v = marker if marker is not None else _v if _v is not None: self["marker"] = _v _v = arg.pop("textfont", None) _v = textfont if textfont is not None else _v if _v is not None: self["textfont"] = _v # Process unknown kwargs # ---------------------- self._process_kwargs(**dict(arg, **kwargs)) # Reset skip_invalid # ------------------ self._skip_invalid = False
[ "def", "__init__", "(", "self", ",", "arg", "=", "None", ",", "marker", "=", "None", ",", "textfont", "=", "None", ",", "*", "*", "kwargs", ")", ":", "super", "(", "Unselected", ",", "self", ")", ".", "__init__", "(", "\"unselected\"", ")", "if", "\"_parent\"", "in", "kwargs", ":", "self", ".", "_parent", "=", "kwargs", "[", "\"_parent\"", "]", "return", "# Validate arg", "# ------------", "if", "arg", "is", "None", ":", "arg", "=", "{", "}", "elif", "isinstance", "(", "arg", ",", "self", ".", "__class__", ")", ":", "arg", "=", "arg", ".", "to_plotly_json", "(", ")", "elif", "isinstance", "(", "arg", ",", "dict", ")", ":", "arg", "=", "_copy", ".", "copy", "(", "arg", ")", "else", ":", "raise", "ValueError", "(", "\"\"\"\\\nThe first argument to the plotly.graph_objs.scatter.Unselected \nconstructor must be a dict or \nan instance of :class:`plotly.graph_objs.scatter.Unselected`\"\"\"", ")", "# Handle skip_invalid", "# -------------------", "self", ".", "_skip_invalid", "=", "kwargs", ".", "pop", "(", "\"skip_invalid\"", ",", "False", ")", "self", ".", "_validate", "=", "kwargs", ".", "pop", "(", "\"_validate\"", ",", "True", ")", "# Populate data dict with properties", "# ----------------------------------", "_v", "=", "arg", ".", "pop", "(", "\"marker\"", ",", "None", ")", "_v", "=", "marker", "if", "marker", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"marker\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"textfont\"", ",", "None", ")", "_v", "=", "textfont", "if", "textfont", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"textfont\"", "]", "=", "_v", "# Process unknown kwargs", "# ----------------------", "self", ".", "_process_kwargs", "(", "*", "*", "dict", "(", "arg", ",", "*", "*", "kwargs", ")", ")", "# Reset skip_invalid", "# ------------------", "self", ".", "_skip_invalid", "=", "False" ]
[ 85, 4 ]
[ 150, 34 ]
python
en
['en', 'error', 'th']
False
extend_auth_map
(nodes, key, constraint)
Context manager to add a new auth rule to the auth map and remove it on exit. :param nodes: nodes list which auth maps should be changed :param key: str gotten from AuthActionAdd(...).get_action_id() :param constraint: AuthConstraint
Context manager to add a new auth rule to the auth map and remove it on exit.
def extend_auth_map(nodes, key, constraint): """ Context manager to add a new auth rule to the auth map and remove it on exit. :param nodes: nodes list which auth maps should be changed :param key: str gotten from AuthActionAdd(...).get_action_id() :param constraint: AuthConstraint """ for node in nodes: node.write_req_validator.auth_map[key] = constraint yield for node in nodes: node.write_req_validator.auth_map.pop(key, None)
[ "def", "extend_auth_map", "(", "nodes", ",", "key", ",", "constraint", ")", ":", "for", "node", "in", "nodes", ":", "node", ".", "write_req_validator", ".", "auth_map", "[", "key", "]", "=", "constraint", "yield", "for", "node", "in", "nodes", ":", "node", ".", "write_req_validator", ".", "auth_map", ".", "pop", "(", "key", ",", "None", ")" ]
[ 19, 0 ]
[ 31, 56 ]
python
en
['en', 'error', 'th']
False
test_auth_txn_with_deprecated_key
(tconf, tdir, allPluginsPath, txnPoolNodeSet, looper, sdk_wallet_trustee, sdk_pool_handle)
Add to the auth_map a fake rule Send AUTH_RULE txn to change this fake rule (and set the fake key to the config state) Send GET_AUTH_RULE txn and check that the fake rule was changed Remove the fake auth rule from the map Check that we can't get the fake auth rule Restart the last node with its state regeneration Check that nodes data is equal after changing the existing auth rule (restarted node regenerate config state)
Add to the auth_map a fake rule Send AUTH_RULE txn to change this fake rule (and set the fake key to the config state) Send GET_AUTH_RULE txn and check that the fake rule was changed Remove the fake auth rule from the map Check that we can't get the fake auth rule Restart the last node with its state regeneration Check that nodes data is equal after changing the existing auth rule (restarted node regenerate config state)
def test_auth_txn_with_deprecated_key(tconf, tdir, allPluginsPath, txnPoolNodeSet, looper, sdk_wallet_trustee, sdk_pool_handle): """ Add to the auth_map a fake rule Send AUTH_RULE txn to change this fake rule (and set the fake key to the config state) Send GET_AUTH_RULE txn and check that the fake rule was changed Remove the fake auth rule from the map Check that we can't get the fake auth rule Restart the last node with its state regeneration Check that nodes data is equal after changing the existing auth rule (restarted node regenerate config state) """ fake_txn_type = "100002" fake_key = AuthActionAdd(txn_type=fake_txn_type, field="*", value="*").get_action_id() fake_constraint = one_trustee_constraint new_auth_constraint = AuthConstraint(role=STEWARD, sig_count=1, need_to_be_owner=False).as_dict # Add to the auth_map a fake rule with extend_auth_map(txnPoolNodeSet, fake_key, fake_constraint): # Send AUTH_RULE txn to change this fake rule (and set the fake key to the config state) sdk_send_and_check_auth_rule_request(looper, sdk_pool_handle, sdk_wallet_trustee, auth_action=ADD_PREFIX, auth_type=fake_txn_type, field='*', new_value='*', constraint=new_auth_constraint) # Send GET_AUTH_RULE txn and check that the fake rule was changed result = sdk_send_and_check_get_auth_rule_request( looper, sdk_pool_handle, sdk_wallet_trustee, auth_type=fake_txn_type, auth_action=ADD_PREFIX, field="*", new_value="*" )[0][1]["result"][DATA][0] assert result[AUTH_TYPE] == fake_txn_type assert result[CONSTRAINT] == new_auth_constraint # Remove the fake auth rule from the map # Check that we can't get the fake auth rule with pytest.raises(RequestNackedException, match="not found in authorization map"): sdk_send_and_check_auth_rule_request(looper, sdk_pool_handle, sdk_wallet_trustee, auth_action=ADD_PREFIX, auth_type=fake_txn_type, field='*', new_value='*', constraint=AuthConstraint(role=STEWARD, sig_count=2, need_to_be_owner=False).as_dict) resp = sdk_send_and_check_get_auth_rule_request(looper, sdk_pool_handle, sdk_wallet_trustee) assert all(rule[AUTH_TYPE] != fake_txn_type for rule in resp[0][1]["result"][DATA]) with pytest.raises(RequestNackedException, match="not found in authorization map"): sdk_send_and_check_get_auth_rule_request( looper, sdk_pool_handle, sdk_wallet_trustee, auth_type=fake_txn_type, auth_action=ADD_PREFIX, field="*", new_value="*" ) # Restart the last node with its state regeneration ensure_all_nodes_have_same_data(looper, txnPoolNodeSet) node_to_stop = txnPoolNodeSet[-1] node_state = node_to_stop.states[CONFIG_LEDGER_ID] assert not node_state.isEmpty state_db_path = node_state._kv.db_path node_to_stop.cleanupOnStopping = False node_to_stop.stop() looper.removeProdable(node_to_stop) ensure_node_disconnected(looper, node_to_stop, txnPoolNodeSet[:-1]) shutil.rmtree(state_db_path) config_helper = NodeConfigHelper(node_to_stop.name, tconf, chroot=tdir) restarted_node = TestNode( node_to_stop.name, config_helper=config_helper, config=tconf, pluginPaths=allPluginsPath, ha=node_to_stop.nodestack.ha, cliha=node_to_stop.clientstack.ha) looper.add(restarted_node) txnPoolNodeSet[-1] = restarted_node # Check that nodes data is equal (restarted node regenerate config state) looper.run(checkNodesConnected(txnPoolNodeSet)) ensureElectionsDone(looper, txnPoolNodeSet, customTimeout=30) sdk_send_and_check_auth_rule_request(looper, sdk_pool_handle, sdk_wallet_trustee, auth_action=ADD_PREFIX, auth_type=NYM, field=ROLE, new_value=STEWARD, constraint=AuthConstraint(role=STEWARD, sig_count=2, need_to_be_owner=False).as_dict) ensure_all_nodes_have_same_data(looper, txnPoolNodeSet, custom_timeout=20)
[ "def", "test_auth_txn_with_deprecated_key", "(", "tconf", ",", "tdir", ",", "allPluginsPath", ",", "txnPoolNodeSet", ",", "looper", ",", "sdk_wallet_trustee", ",", "sdk_pool_handle", ")", ":", "fake_txn_type", "=", "\"100002\"", "fake_key", "=", "AuthActionAdd", "(", "txn_type", "=", "fake_txn_type", ",", "field", "=", "\"*\"", ",", "value", "=", "\"*\"", ")", ".", "get_action_id", "(", ")", "fake_constraint", "=", "one_trustee_constraint", "new_auth_constraint", "=", "AuthConstraint", "(", "role", "=", "STEWARD", ",", "sig_count", "=", "1", ",", "need_to_be_owner", "=", "False", ")", ".", "as_dict", "# Add to the auth_map a fake rule", "with", "extend_auth_map", "(", "txnPoolNodeSet", ",", "fake_key", ",", "fake_constraint", ")", ":", "# Send AUTH_RULE txn to change this fake rule (and set the fake key to the config state)", "sdk_send_and_check_auth_rule_request", "(", "looper", ",", "sdk_pool_handle", ",", "sdk_wallet_trustee", ",", "auth_action", "=", "ADD_PREFIX", ",", "auth_type", "=", "fake_txn_type", ",", "field", "=", "'*'", ",", "new_value", "=", "'*'", ",", "constraint", "=", "new_auth_constraint", ")", "# Send GET_AUTH_RULE txn and check that the fake rule was changed", "result", "=", "sdk_send_and_check_get_auth_rule_request", "(", "looper", ",", "sdk_pool_handle", ",", "sdk_wallet_trustee", ",", "auth_type", "=", "fake_txn_type", ",", "auth_action", "=", "ADD_PREFIX", ",", "field", "=", "\"*\"", ",", "new_value", "=", "\"*\"", ")", "[", "0", "]", "[", "1", "]", "[", "\"result\"", "]", "[", "DATA", "]", "[", "0", "]", "assert", "result", "[", "AUTH_TYPE", "]", "==", "fake_txn_type", "assert", "result", "[", "CONSTRAINT", "]", "==", "new_auth_constraint", "# Remove the fake auth rule from the map", "# Check that we can't get the fake auth rule", "with", "pytest", ".", "raises", "(", "RequestNackedException", ",", "match", "=", "\"not found in authorization map\"", ")", ":", "sdk_send_and_check_auth_rule_request", "(", "looper", ",", "sdk_pool_handle", ",", "sdk_wallet_trustee", ",", "auth_action", "=", "ADD_PREFIX", ",", "auth_type", "=", "fake_txn_type", ",", "field", "=", "'*'", ",", "new_value", "=", "'*'", ",", "constraint", "=", "AuthConstraint", "(", "role", "=", "STEWARD", ",", "sig_count", "=", "2", ",", "need_to_be_owner", "=", "False", ")", ".", "as_dict", ")", "resp", "=", "sdk_send_and_check_get_auth_rule_request", "(", "looper", ",", "sdk_pool_handle", ",", "sdk_wallet_trustee", ")", "assert", "all", "(", "rule", "[", "AUTH_TYPE", "]", "!=", "fake_txn_type", "for", "rule", "in", "resp", "[", "0", "]", "[", "1", "]", "[", "\"result\"", "]", "[", "DATA", "]", ")", "with", "pytest", ".", "raises", "(", "RequestNackedException", ",", "match", "=", "\"not found in authorization map\"", ")", ":", "sdk_send_and_check_get_auth_rule_request", "(", "looper", ",", "sdk_pool_handle", ",", "sdk_wallet_trustee", ",", "auth_type", "=", "fake_txn_type", ",", "auth_action", "=", "ADD_PREFIX", ",", "field", "=", "\"*\"", ",", "new_value", "=", "\"*\"", ")", "# Restart the last node with its state regeneration", "ensure_all_nodes_have_same_data", "(", "looper", ",", "txnPoolNodeSet", ")", "node_to_stop", "=", "txnPoolNodeSet", "[", "-", "1", "]", "node_state", "=", "node_to_stop", ".", "states", "[", "CONFIG_LEDGER_ID", "]", "assert", "not", "node_state", ".", "isEmpty", "state_db_path", "=", "node_state", ".", "_kv", ".", "db_path", "node_to_stop", ".", "cleanupOnStopping", "=", "False", "node_to_stop", ".", "stop", "(", ")", "looper", ".", "removeProdable", "(", "node_to_stop", ")", "ensure_node_disconnected", "(", "looper", ",", "node_to_stop", ",", "txnPoolNodeSet", "[", ":", "-", "1", "]", ")", "shutil", ".", "rmtree", "(", "state_db_path", ")", "config_helper", "=", "NodeConfigHelper", "(", "node_to_stop", ".", "name", ",", "tconf", ",", "chroot", "=", "tdir", ")", "restarted_node", "=", "TestNode", "(", "node_to_stop", ".", "name", ",", "config_helper", "=", "config_helper", ",", "config", "=", "tconf", ",", "pluginPaths", "=", "allPluginsPath", ",", "ha", "=", "node_to_stop", ".", "nodestack", ".", "ha", ",", "cliha", "=", "node_to_stop", ".", "clientstack", ".", "ha", ")", "looper", ".", "add", "(", "restarted_node", ")", "txnPoolNodeSet", "[", "-", "1", "]", "=", "restarted_node", "# Check that nodes data is equal (restarted node regenerate config state)", "looper", ".", "run", "(", "checkNodesConnected", "(", "txnPoolNodeSet", ")", ")", "ensureElectionsDone", "(", "looper", ",", "txnPoolNodeSet", ",", "customTimeout", "=", "30", ")", "sdk_send_and_check_auth_rule_request", "(", "looper", ",", "sdk_pool_handle", ",", "sdk_wallet_trustee", ",", "auth_action", "=", "ADD_PREFIX", ",", "auth_type", "=", "NYM", ",", "field", "=", "ROLE", ",", "new_value", "=", "STEWARD", ",", "constraint", "=", "AuthConstraint", "(", "role", "=", "STEWARD", ",", "sig_count", "=", "2", ",", "need_to_be_owner", "=", "False", ")", ".", "as_dict", ")", "ensure_all_nodes_have_same_data", "(", "looper", ",", "txnPoolNodeSet", ",", "custom_timeout", "=", "20", ")" ]
[ 34, 0 ]
[ 148, 78 ]
python
en
['en', 'error', 'th']
False
CameraPoints.flip
(self, bev_direction='horizontal')
Flip the boxes in BEV along given BEV direction.
Flip the boxes in BEV along given BEV direction.
def flip(self, bev_direction='horizontal'): """Flip the boxes in BEV along given BEV direction.""" if bev_direction == 'horizontal': self.tensor[:, 0] = -self.tensor[:, 0] elif bev_direction == 'vertical': self.tensor[:, 2] = -self.tensor[:, 2]
[ "def", "flip", "(", "self", ",", "bev_direction", "=", "'horizontal'", ")", ":", "if", "bev_direction", "==", "'horizontal'", ":", "self", ".", "tensor", "[", ":", ",", "0", "]", "=", "-", "self", ".", "tensor", "[", ":", ",", "0", "]", "elif", "bev_direction", "==", "'vertical'", ":", "self", ".", "tensor", "[", ":", ",", "2", "]", "=", "-", "self", ".", "tensor", "[", ":", ",", "2", "]" ]
[ 27, 4 ]
[ 32, 50 ]
python
en
['en', 'da', 'en']
True
CameraPoints.in_range_bev
(self, point_range)
Check whether the points are in the given range. Args: point_range (list | torch.Tensor): The range of point in order of (x_min, y_min, x_max, y_max). Returns: torch.Tensor: Indicating whether each point is inside \ the reference range.
Check whether the points are in the given range.
def in_range_bev(self, point_range): """Check whether the points are in the given range. Args: point_range (list | torch.Tensor): The range of point in order of (x_min, y_min, x_max, y_max). Returns: torch.Tensor: Indicating whether each point is inside \ the reference range. """ in_range_flags = ((self.tensor[:, 0] > point_range[0]) & (self.tensor[:, 2] > point_range[1]) & (self.tensor[:, 0] < point_range[2]) & (self.tensor[:, 2] < point_range[3])) return in_range_flags
[ "def", "in_range_bev", "(", "self", ",", "point_range", ")", ":", "in_range_flags", "=", "(", "(", "self", ".", "tensor", "[", ":", ",", "0", "]", ">", "point_range", "[", "0", "]", ")", "&", "(", "self", ".", "tensor", "[", ":", ",", "2", "]", ">", "point_range", "[", "1", "]", ")", "&", "(", "self", ".", "tensor", "[", ":", ",", "0", "]", "<", "point_range", "[", "2", "]", ")", "&", "(", "self", ".", "tensor", "[", ":", ",", "2", "]", "<", "point_range", "[", "3", "]", ")", ")", "return", "in_range_flags" ]
[ 34, 4 ]
[ 49, 29 ]
python
en
['en', 'en', 'en']
True