Search is not available for this dataset
id
int64
0
10.8M
vector
listlengths
1.54k
1.54k
ast_depth
int64
3
164
ast_data
stringlengths
297
510k
full_path
stringlengths
0
319
code
stringlengths
60
56.5k
14,401
[ 0.02234813943505287, 0.00944200437515974, -0.013226679526269436, -0.04361655190587044, -0.006821412593126297, -0.005089347250759602, 0.0006983793573454022, 0.023484105244278908, -0.02697072923183441, 0.044786255806684494, -0.008171074092388153, 0.009273297153413296, 0.030884746462106705, -...
8
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "config", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "input_ids", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "input_shape_ids", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "input_pronunciation_ids", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "token_type_ids", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "input_mask", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "sequence_labels", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "token_labels", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "choice_labels", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "num_labels", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "num_labels", "value": {"_type": "Name", "_fields": {"id": "config", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "RoCBertForTokenClassification", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "config", "value": {"_type": "Name", "_fields": {"id": "config", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "model", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "torch_device", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "to", "value": {"_type": "Name", "_fields": {"id": "model", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Name", "_fields": {"id": "model", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "input_ids", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "model", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "input_shape_ids", "value": {"_type": "Name", "_fields": {"id": "input_shape_ids", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "input_pronunciation_ids", "value": {"_type": "Name", "_fields": {"id": "input_pronunciation_ids", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "attention_mask", "value": {"_type": "Name", "_fields": {"id": "input_mask", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "token_type_ids", "value": {"_type": "Name", "_fields": {"id": "token_type_ids", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "labels", "value": {"_type": "Name", "_fields": {"id": "token_labels", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "result", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "shape", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "logits", "value": {"_type": "Name", "_fields": {"id": "result", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "batch_size", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "seq_length", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "num_labels", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "parent", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}], "name": "create_and_check_for_token_classification", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def create_and_check_for_token_classification( self, config, input_ids, input_shape_ids, input_pronunciation_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels, ): config.num_labels = self.num_labels model = RoCBertForTokenClassification(config=config) model.to(torch_device) model.eval() result = model( input_ids, input_shape_ids=input_shape_ids, input_pronunciation_ids=input_pronunciation_ids, attention_mask=input_mask, token_type_ids=token_type_ids, labels=token_labels, ) self.parent.assertEqual(result.logits.shape, (self.batch_size, self.seq_length, self.num_labels))
14,402
[ 0.016186196357011795, -0.005488060414791107, -0.006516892462968826, -0.011251240037381649, 0.015945466235280037, -0.009554670192301273, 0.01526913046836853, 0.026388542726635933, -0.022009557113051414, 0.06171846762299538, -0.006694573909044266, -0.018570564687252045, 0.04204742610454559, ...
11
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "config", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "input_ids", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "input_shape_ids", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "input_pronunciation_ids", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "token_type_ids", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "input_mask", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "sequence_labels", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "token_labels", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "choice_labels", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "num_choices", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "num_choices", "value": {"_type": "Name", "_fields": {"id": "config", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "RoCBertForMultipleChoice", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "config", "value": {"_type": "Name", "_fields": {"id": "config", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "model", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "torch_device", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "to", "value": {"_type": "Name", "_fields": {"id": "model", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Name", "_fields": {"id": "model", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contiguous", "value": {"_type": "Call", "_fields": {"args": [{"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "num_choices", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "expand", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "unsqueeze", "value": {"_type": "Name", "_fields": {"id": "input_ids", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "multiple_choice_inputs_ids", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contiguous", "value": {"_type": "Call", "_fields": {"args": [{"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "num_choices", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "expand", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "unsqueeze", "value": {"_type": "Name", "_fields": {"id": "input_shape_ids", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "multiple_choice_inputs_shape_ids", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contiguous", "value": {"_type": "Call", "_fields": {"args": [{"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "num_choices", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "expand", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "unsqueeze", "value": {"_type": "Name", "_fields": {"id": "input_pronunciation_ids", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "multiple_choice_inputs_pronunciation_ids", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contiguous", "value": {"_type": "Call", "_fields": {"args": [{"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "num_choices", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "expand", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "unsqueeze", "value": {"_type": "Name", "_fields": {"id": "token_type_ids", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "multiple_choice_token_type_ids", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contiguous", "value": {"_type": "Call", "_fields": {"args": [{"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "num_choices", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "expand", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "unsqueeze", "value": {"_type": "Name", "_fields": {"id": "input_mask", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "multiple_choice_input_mask", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "multiple_choice_inputs_ids", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "model", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "input_shape_ids", "value": {"_type": "Name", "_fields": {"id": "multiple_choice_inputs_shape_ids", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "input_pronunciation_ids", "value": {"_type": "Name", "_fields": {"id": "multiple_choice_inputs_pronunciation_ids", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "attention_mask", "value": {"_type": "Name", "_fields": {"id": "multiple_choice_input_mask", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "token_type_ids", "value": {"_type": "Name", "_fields": {"id": "multiple_choice_token_type_ids", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "labels", "value": {"_type": "Name", "_fields": {"id": "choice_labels", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "result", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "shape", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "logits", "value": {"_type": "Name", "_fields": {"id": "result", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "batch_size", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "num_choices", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "parent", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}], "name": "create_and_check_for_multiple_choice", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def create_and_check_for_multiple_choice( self, config, input_ids, input_shape_ids, input_pronunciation_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels, ): config.num_choices = self.num_choices model = RoCBertForMultipleChoice(config=config) model.to(torch_device) model.eval() multiple_choice_inputs_ids = input_ids.unsqueeze(1).expand(-1, self.num_choices, -1).contiguous() multiple_choice_inputs_shape_ids = input_shape_ids.unsqueeze(1).expand(-1, self.num_choices, -1).contiguous() multiple_choice_inputs_pronunciation_ids = ( input_pronunciation_ids.unsqueeze(1).expand(-1, self.num_choices, -1).contiguous() ) multiple_choice_token_type_ids = token_type_ids.unsqueeze(1).expand(-1, self.num_choices, -1).contiguous() multiple_choice_input_mask = input_mask.unsqueeze(1).expand(-1, self.num_choices, -1).contiguous() result = model( multiple_choice_inputs_ids, input_shape_ids=multiple_choice_inputs_shape_ids, input_pronunciation_ids=multiple_choice_inputs_pronunciation_ids, attention_mask=multiple_choice_input_mask, token_type_ids=multiple_choice_token_type_ids, labels=choice_labels, ) self.parent.assertEqual(result.logits.shape, (self.batch_size, self.num_choices))
14,403
[ 0.015310327522456646, 0.021713633090257645, -0.0072618811391294, -0.026521652936935425, -0.015066603198647499, -0.0075166840106248856, 0.014612389728426933, 0.050428807735443115, -0.03540651872754097, 0.05326487496495247, -0.005877083167433739, 0.003780498867854476, 0.019409330561757088, -...
8
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "config", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "input_ids", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "input_shape_ids", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "input_pronunciation_ids", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "token_type_ids", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "input_mask", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "sequence_labels", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "token_labels", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "choice_labels", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "RoCBertForPreTraining", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "config", "value": {"_type": "Name", "_fields": {"id": "config", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "model", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "torch_device", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "to", "value": {"_type": "Name", "_fields": {"id": "model", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Name", "_fields": {"id": "model", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "input_ids", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "input_shape_ids", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "input_pronunciation_ids", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "model", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "attention_mask", "value": {"_type": "Name", "_fields": {"id": "input_mask", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "token_type_ids", "value": {"_type": "Name", "_fields": {"id": "token_type_ids", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "attack_input_ids", "value": {"_type": "Name", "_fields": {"id": "input_ids", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "attack_input_shape_ids", "value": {"_type": "Name", "_fields": {"id": "input_shape_ids", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "attack_input_pronunciation_ids", "value": {"_type": "Name", "_fields": {"id": "input_pronunciation_ids", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "attack_attention_mask", "value": {"_type": "Name", "_fields": {"id": "input_mask", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "attack_token_type_ids", "value": {"_type": "Name", "_fields": {"id": "token_type_ids", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "labels_input_ids", "value": {"_type": "Name", "_fields": {"id": "token_labels", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "labels_input_shape_ids", "value": {"_type": "Name", "_fields": {"id": "input_shape_ids", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "labels_input_pronunciation_ids", "value": {"_type": "Name", "_fields": {"id": "input_pronunciation_ids", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "labels_attention_mask", "value": {"_type": "Name", "_fields": {"id": "input_mask", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "labels_token_type_ids", "value": {"_type": "Name", "_fields": {"id": "token_type_ids", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "result", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "shape", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "logits", "value": {"_type": "Name", "_fields": {"id": "result", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "batch_size", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "seq_length", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "vocab_size", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "parent", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}], "name": "create_and_check_for_pretraining", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def create_and_check_for_pretraining( self, config, input_ids, input_shape_ids, input_pronunciation_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels, ): model = RoCBertForPreTraining(config=config) model.to(torch_device) model.eval() result = model( input_ids, input_shape_ids, input_pronunciation_ids, attention_mask=input_mask, token_type_ids=token_type_ids, attack_input_ids=input_ids, attack_input_shape_ids=input_shape_ids, attack_input_pronunciation_ids=input_pronunciation_ids, attack_attention_mask=input_mask, attack_token_type_ids=token_type_ids, labels_input_ids=token_labels, labels_input_shape_ids=input_shape_ids, labels_input_pronunciation_ids=input_pronunciation_ids, labels_attention_mask=input_mask, labels_token_type_ids=token_type_ids, ) self.parent.assertEqual(result.logits.shape, (self.batch_size, self.seq_length, self.vocab_size))
14,404
[ -0.002111666603013873, -0.0024131264071911573, -0.002443562261760235, -0.045497212558984756, -0.0003440335567574948, 0.033160559833049774, 0.007855341769754887, 0.03663893789052963, 0.007455328479409218, 0.052593108266592026, 0.0018000617856159806, -0.014933845959603786, 0.028290826827287674...
12
{"_type": "Module", "_fields": {"body": [{"_type": "ClassDef", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "IfExp", "_fields": {"body": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "RoCBertModel", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "RoCBertForMaskedLM", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "RoCBertForCausalLM", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "RoCBertForMultipleChoice", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "RoCBertForQuestionAnswering", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "RoCBertForSequenceClassification", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "RoCBertForTokenClassification", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "RoCBertForPreTraining", "ctx": {"_type": "Load", "_fields": {}}}}]}}, "test": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "is_torch_available", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "orelse": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "all_model_classes", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "IfExp", "_fields": {"body": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "RoCBertForCausalLM", "ctx": {"_type": "Load", "_fields": {}}}}]}}, "test": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "is_torch_available", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "orelse": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "all_generative_model_classes", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "inputs_dict", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "model_class", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "return_labels", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [{"_type": "Constant", "_fields": {"kind": null, "value": false}}], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "inputs_dict", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "model_class", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_prepare_for_class", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "super", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "return_labels", "value": {"_type": "Name", "_fields": {"id": "return_labels", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "inputs_dict", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "If", "_fields": {"body": [{"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "batch_size", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "seq_length", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "zeros", "value": {"_type": "Name", "_fields": {"id": "torch", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "dtype", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "long", "value": {"_type": "Name", "_fields": {"id": "torch", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "keyword", "_fields": {"arg": "device", "value": {"_type": "Name", "_fields": {"id": "torch_device", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "labels_input_ids"}}, "value": {"_type": "Name", "_fields": {"id": "inputs_dict", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "batch_size", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "seq_length", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "zeros", "value": {"_type": "Name", "_fields": {"id": "torch", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "dtype", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "long", "value": {"_type": "Name", "_fields": {"id": "torch", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "keyword", "_fields": {"arg": "device", "value": {"_type": "Name", "_fields": {"id": "torch_device", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "labels_input_shape_ids"}}, "value": {"_type": "Name", "_fields": {"id": "inputs_dict", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "batch_size", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "seq_length", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "zeros", "value": {"_type": "Name", "_fields": {"id": "torch", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "dtype", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "long", "value": {"_type": "Name", "_fields": {"id": "torch", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "keyword", "_fields": {"arg": "device", "value": {"_type": "Name", "_fields": {"id": "torch_device", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "labels_input_pronunciation_ids"}}, "value": {"_type": "Name", "_fields": {"id": "inputs_dict", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "batch_size", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "seq_length", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "zeros", "value": {"_type": "Name", "_fields": {"id": "torch", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "dtype", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "long", "value": {"_type": "Name", "_fields": {"id": "torch", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "keyword", "_fields": {"arg": "device", "value": {"_type": "Name", "_fields": {"id": "torch_device", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "attack_input_ids"}}, "value": {"_type": "Name", "_fields": {"id": "inputs_dict", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "batch_size", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "seq_length", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "zeros", "value": {"_type": "Name", "_fields": {"id": "torch", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "dtype", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "long", "value": {"_type": "Name", "_fields": {"id": "torch", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "keyword", "_fields": {"arg": "device", "value": {"_type": "Name", "_fields": {"id": "torch_device", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "attack_input_shape_ids"}}, "value": {"_type": "Name", "_fields": {"id": "inputs_dict", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "batch_size", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "seq_length", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "zeros", "value": {"_type": "Name", "_fields": {"id": "torch", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "dtype", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "long", "value": {"_type": "Name", "_fields": {"id": "torch", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "keyword", "_fields": {"arg": "device", "value": {"_type": "Name", "_fields": {"id": "torch_device", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "attack_input_pronunciation_ids"}}, "value": {"_type": "Name", "_fields": {"id": "inputs_dict", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "In", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "model_class", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "MODEL_FOR_PRETRAINING_MAPPING", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "get_values", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}]}}, "orelse": []}}], "test": {"_type": "Name", "_fields": {"id": "return_labels", "ctx": {"_type": "Load", "_fields": {}}}}, "orelse": []}}, {"_type": "Return", "_fields": {"value": {"_type": "Name", "_fields": {"id": "inputs_dict", "ctx": {"_type": "Load", "_fields": {}}}}}}], "name": "_prepare_for_class", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "RoCBertModelTester", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "ConfigTester", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "config_class", "value": {"_type": "Name", "_fields": {"id": "RoCBertConfig", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "hidden_size", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 37}}}}]}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "config_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}], "name": "setUp", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "run_common_tests", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "config_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}], "name": "test_config", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "prepare_config_and_inputs", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "config_and_inputs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Starred", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "value": {"_type": "Name", "_fields": {"id": "config_and_inputs", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "create_and_check_model", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}], "name": "test_model", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "prepare_config_and_inputs", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "config_and_inputs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "For", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Name", "_fields": {"id": "type", "ctx": {"_type": "Load", "_fields": {}}}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "position_embedding_type", "value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "config_and_inputs", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Starred", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "value": {"_type": "Name", "_fields": {"id": "config_and_inputs", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "create_and_check_model", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}], "iter": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": "absolute"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "relative_key"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "relative_key_query"}}]}}, "orelse": [], "target": {"_type": "Name", "_fields": {"id": "type", "ctx": {"_type": "Store", "_fields": {}}}}, "type_comment": null}}], "name": "test_model_various_embeddings", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "prepare_config_and_inputs", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "config_and_inputs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Starred", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "value": {"_type": "Name", "_fields": {"id": "config_and_inputs", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "create_and_check_for_masked_lm", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}], "name": "test_for_masked_lm", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "prepare_config_and_inputs", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "config_and_inputs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Starred", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "value": {"_type": "Name", "_fields": {"id": "config_and_inputs", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "create_and_check_for_multiple_choice", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}], "name": "test_for_multiple_choice", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "prepare_config_and_inputs_for_decoder", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "config_and_inputs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Starred", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "value": {"_type": "Name", "_fields": {"id": "config_and_inputs", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "create_and_check_decoder_model_past_large_inputs", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}], "name": "test_decoder_model_past_with_large_inputs", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "prepare_config_and_inputs_for_decoder", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "config_and_inputs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": "relative_key"}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "position_embedding_type", "value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "config_and_inputs", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Starred", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "value": {"_type": "Name", "_fields": {"id": "config_and_inputs", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "create_and_check_decoder_model_past_large_inputs", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}], "name": "test_decoder_model_past_with_large_inputs_relative_pos_emb", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "prepare_config_and_inputs", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "config_and_inputs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Starred", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "value": {"_type": "Name", "_fields": {"id": "config_and_inputs", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "create_and_check_for_question_answering", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}], "name": "test_for_question_answering", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "prepare_config_and_inputs", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "config_and_inputs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Starred", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "value": {"_type": "Name", "_fields": {"id": "config_and_inputs", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "create_and_check_for_sequence_classification", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}], "name": "test_for_sequence_classification", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "prepare_config_and_inputs", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "config_and_inputs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Starred", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "value": {"_type": "Name", "_fields": {"id": "config_and_inputs", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "create_and_check_for_token_classification", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}], "name": "test_for_token_classification", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "prepare_config_and_inputs", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "config_and_inputs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Starred", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "value": {"_type": "Name", "_fields": {"id": "config_and_inputs", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "create_and_check_for_pretraining", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}], "name": "test_for_pretraining", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "prepare_config_and_inputs_for_decoder", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "config_and_inputs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Starred", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "value": {"_type": "Name", "_fields": {"id": "config_and_inputs", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "create_and_check_model_as_decoder", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}], "name": "test_model_as_decoder", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "prepare_config_and_inputs_for_decoder", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}, "targets": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "config", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "input_ids", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "input_shape_ids", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "input_pronunciation_ids", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "token_type_ids", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "input_mask", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "sequence_labels", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "token_labels", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "choice_labels", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "encoder_hidden_states", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "encoder_attention_mask", "ctx": {"_type": "Store", "_fields": {}}}}]}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": null}}, "targets": [{"_type": "Name", "_fields": {"id": "input_mask", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "config", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "input_ids", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "input_shape_ids", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "input_pronunciation_ids", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "token_type_ids", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "input_mask", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "sequence_labels", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "token_labels", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "choice_labels", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "encoder_hidden_states", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "encoder_attention_mask", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "create_and_check_model_as_decoder", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}], "name": "test_model_as_decoder_with_default_input_mask", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "For", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "model_name", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "from_pretrained", "value": {"_type": "Name", "_fields": {"id": "RoCBertModel", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "model", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "model", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertIsNotNone", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "iter": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}}}, "value": {"_type": "Name", "_fields": {"id": "ROC_BERT_PRETRAINED_MODEL_ARCHIVE_LIST", "ctx": {"_type": "Load", "_fields": {}}}}}}, "orelse": [], "target": {"_type": "Name", "_fields": {"id": "model_name", "ctx": {"_type": "Store", "_fields": {}}}}, "type_comment": null}}], "name": "test_model_from_pretrained", "returns": null, "type_params": [], "type_comment": null, "decorator_list": [{"_type": "Name", "_fields": {"id": "slow", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "name": "RoCBertModelTest", "bases": [{"_type": "Name", "_fields": {"id": "ModelTesterMixin", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "TestCase", "value": {"_type": "Name", "_fields": {"id": "unittest", "ctx": {"_type": "Load", "_fields": {}}}}}}], "keywords": [], "type_params": [], "decorator_list": []}}], "type_ignores": []}}
class RoCBertModelTest(ModelTesterMixin, unittest.TestCase): all_model_classes = ( ( RoCBertModel, RoCBertForMaskedLM, RoCBertForCausalLM, RoCBertForMultipleChoice, RoCBertForQuestionAnswering, RoCBertForSequenceClassification, RoCBertForTokenClassification, RoCBertForPreTraining, ) if is_torch_available() else () ) all_generative_model_classes = (RoCBertForCausalLM,) if is_torch_available() else () # special case for ForPreTraining model def _prepare_for_class(self, inputs_dict, model_class, return_labels=False): inputs_dict = super()._prepare_for_class(inputs_dict, model_class, return_labels=return_labels) if return_labels: if model_class in get_values(MODEL_FOR_PRETRAINING_MAPPING): inputs_dict["labels_input_ids"] = torch.zeros( (self.model_tester.batch_size, self.model_tester.seq_length), dtype=torch.long, device=torch_device ) inputs_dict["labels_input_shape_ids"] = torch.zeros( (self.model_tester.batch_size, self.model_tester.seq_length), dtype=torch.long, device=torch_device ) inputs_dict["labels_input_pronunciation_ids"] = torch.zeros( (self.model_tester.batch_size, self.model_tester.seq_length), dtype=torch.long, device=torch_device ) inputs_dict["attack_input_ids"] = torch.zeros( (self.model_tester.batch_size, self.model_tester.seq_length), dtype=torch.long, device=torch_device ) inputs_dict["attack_input_shape_ids"] = torch.zeros( (self.model_tester.batch_size, self.model_tester.seq_length), dtype=torch.long, device=torch_device ) inputs_dict["attack_input_pronunciation_ids"] = torch.zeros( (self.model_tester.batch_size, self.model_tester.seq_length), dtype=torch.long, device=torch_device ) return inputs_dict def setUp(self): self.model_tester = RoCBertModelTester(self) self.config_tester = ConfigTester(self, config_class=RoCBertConfig, hidden_size=37) def test_config(self): self.config_tester.run_common_tests() def test_model(self): config_and_inputs = self.model_tester.prepare_config_and_inputs() self.model_tester.create_and_check_model(*config_and_inputs) def test_model_various_embeddings(self): config_and_inputs = self.model_tester.prepare_config_and_inputs() for type in ["absolute", "relative_key", "relative_key_query"]: config_and_inputs[0].position_embedding_type = type self.model_tester.create_and_check_model(*config_and_inputs) def test_for_masked_lm(self): config_and_inputs = self.model_tester.prepare_config_and_inputs() self.model_tester.create_and_check_for_masked_lm(*config_and_inputs) def test_for_multiple_choice(self): config_and_inputs = self.model_tester.prepare_config_and_inputs() self.model_tester.create_and_check_for_multiple_choice(*config_and_inputs) def test_decoder_model_past_with_large_inputs(self): config_and_inputs = self.model_tester.prepare_config_and_inputs_for_decoder() self.model_tester.create_and_check_decoder_model_past_large_inputs(*config_and_inputs) def test_decoder_model_past_with_large_inputs_relative_pos_emb(self): config_and_inputs = self.model_tester.prepare_config_and_inputs_for_decoder() config_and_inputs[0].position_embedding_type = "relative_key" self.model_tester.create_and_check_decoder_model_past_large_inputs(*config_and_inputs) def test_for_question_answering(self): config_and_inputs = self.model_tester.prepare_config_and_inputs() self.model_tester.create_and_check_for_question_answering(*config_and_inputs) def test_for_sequence_classification(self): config_and_inputs = self.model_tester.prepare_config_and_inputs() self.model_tester.create_and_check_for_sequence_classification(*config_and_inputs) def test_for_token_classification(self): config_and_inputs = self.model_tester.prepare_config_and_inputs() self.model_tester.create_and_check_for_token_classification(*config_and_inputs) def test_for_pretraining(self): config_and_inputs = self.model_tester.prepare_config_and_inputs() self.model_tester.create_and_check_for_pretraining(*config_and_inputs) def test_model_as_decoder(self): config_and_inputs = self.model_tester.prepare_config_and_inputs_for_decoder() self.model_tester.create_and_check_model_as_decoder(*config_and_inputs) def test_model_as_decoder_with_default_input_mask(self): # This regression test was failing with PyTorch < 1.3 ( config, input_ids, input_shape_ids, input_pronunciation_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels, encoder_hidden_states, encoder_attention_mask, ) = self.model_tester.prepare_config_and_inputs_for_decoder() input_mask = None self.model_tester.create_and_check_model_as_decoder( config, input_ids, input_shape_ids, input_pronunciation_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels, encoder_hidden_states, encoder_attention_mask, ) @slow def test_model_from_pretrained(self): for model_name in ROC_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]: model = RoCBertModel.from_pretrained(model_name) self.assertIsNotNone(model)
14,405
[ 0.018078744411468506, 0.033660124987363815, -0.0005839624791406095, -0.07565927505493164, -0.009522558189928532, 0.004006640519946814, 0.04117393493652344, 0.012519394978880882, -0.04128251597285271, 0.026537207886576653, -0.01770957000553608, -0.0158311165869236, 0.007817835547029972, -0....
11
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "inputs_dict", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "model_class", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "return_labels", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [{"_type": "Constant", "_fields": {"kind": null, "value": false}}], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "inputs_dict", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "model_class", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_prepare_for_class", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "super", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "return_labels", "value": {"_type": "Name", "_fields": {"id": "return_labels", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "inputs_dict", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "If", "_fields": {"body": [{"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "batch_size", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "seq_length", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "zeros", "value": {"_type": "Name", "_fields": {"id": "torch", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "dtype", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "long", "value": {"_type": "Name", "_fields": {"id": "torch", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "keyword", "_fields": {"arg": "device", "value": {"_type": "Name", "_fields": {"id": "torch_device", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "labels_input_ids"}}, "value": {"_type": "Name", "_fields": {"id": "inputs_dict", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "batch_size", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "seq_length", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "zeros", "value": {"_type": "Name", "_fields": {"id": "torch", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "dtype", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "long", "value": {"_type": "Name", "_fields": {"id": "torch", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "keyword", "_fields": {"arg": "device", "value": {"_type": "Name", "_fields": {"id": "torch_device", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "labels_input_shape_ids"}}, "value": {"_type": "Name", "_fields": {"id": "inputs_dict", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "batch_size", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "seq_length", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "zeros", "value": {"_type": "Name", "_fields": {"id": "torch", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "dtype", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "long", "value": {"_type": "Name", "_fields": {"id": "torch", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "keyword", "_fields": {"arg": "device", "value": {"_type": "Name", "_fields": {"id": "torch_device", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "labels_input_pronunciation_ids"}}, "value": {"_type": "Name", "_fields": {"id": "inputs_dict", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "batch_size", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "seq_length", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "zeros", "value": {"_type": "Name", "_fields": {"id": "torch", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "dtype", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "long", "value": {"_type": "Name", "_fields": {"id": "torch", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "keyword", "_fields": {"arg": "device", "value": {"_type": "Name", "_fields": {"id": "torch_device", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "attack_input_ids"}}, "value": {"_type": "Name", "_fields": {"id": "inputs_dict", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "batch_size", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "seq_length", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "zeros", "value": {"_type": "Name", "_fields": {"id": "torch", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "dtype", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "long", "value": {"_type": "Name", "_fields": {"id": "torch", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "keyword", "_fields": {"arg": "device", "value": {"_type": "Name", "_fields": {"id": "torch_device", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "attack_input_shape_ids"}}, "value": {"_type": "Name", "_fields": {"id": "inputs_dict", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "batch_size", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "seq_length", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "model_tester", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "zeros", "value": {"_type": "Name", "_fields": {"id": "torch", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "dtype", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "long", "value": {"_type": "Name", "_fields": {"id": "torch", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "keyword", "_fields": {"arg": "device", "value": {"_type": "Name", "_fields": {"id": "torch_device", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "attack_input_pronunciation_ids"}}, "value": {"_type": "Name", "_fields": {"id": "inputs_dict", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "In", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "model_class", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "MODEL_FOR_PRETRAINING_MAPPING", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "get_values", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}]}}, "orelse": []}}], "test": {"_type": "Name", "_fields": {"id": "return_labels", "ctx": {"_type": "Load", "_fields": {}}}}, "orelse": []}}, {"_type": "Return", "_fields": {"value": {"_type": "Name", "_fields": {"id": "inputs_dict", "ctx": {"_type": "Load", "_fields": {}}}}}}], "name": "_prepare_for_class", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def _prepare_for_class(self, inputs_dict, model_class, return_labels=False): inputs_dict = super()._prepare_for_class(inputs_dict, model_class, return_labels=return_labels) if return_labels: if model_class in get_values(MODEL_FOR_PRETRAINING_MAPPING): inputs_dict["labels_input_ids"] = torch.zeros( (self.model_tester.batch_size, self.model_tester.seq_length), dtype=torch.long, device=torch_device ) inputs_dict["labels_input_shape_ids"] = torch.zeros( (self.model_tester.batch_size, self.model_tester.seq_length), dtype=torch.long, device=torch_device ) inputs_dict["labels_input_pronunciation_ids"] = torch.zeros( (self.model_tester.batch_size, self.model_tester.seq_length), dtype=torch.long, device=torch_device ) inputs_dict["attack_input_ids"] = torch.zeros( (self.model_tester.batch_size, self.model_tester.seq_length), dtype=torch.long, device=torch_device ) inputs_dict["attack_input_shape_ids"] = torch.zeros( (self.model_tester.batch_size, self.model_tester.seq_length), dtype=torch.long, device=torch_device ) inputs_dict["attack_input_pronunciation_ids"] = torch.zeros( (self.model_tester.batch_size, self.model_tester.seq_length), dtype=torch.long, device=torch_device ) return inputs_dict
14,406
[ 0.009350803680717945, -0.0058825272135436535, 0.01632268726825714, -0.004389813635498285, 0.002911821473389864, 0.02715737372636795, 0.012330342084169388, 0.053702350705862045, 0.0009657001355662942, 0.03130281716585159, -0.022199327126145363, -0.01118210144340992, 0.035401154309511185, 0....
8
{"_type": "Module", "_fields": {"body": [{"_type": "ClassDef", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "weiweishi/roc-bert-base-zh"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "from_pretrained", "value": {"_type": "Name", "_fields": {"id": "RoCBertForMaskedLM", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "model", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 101}}, {"_type": "Constant", "_fields": {"kind": null, "value": 144}}, {"_type": "Constant", "_fields": {"kind": null, "value": 143}}, {"_type": "Constant", "_fields": {"kind": null, "value": 7027}}, {"_type": "Constant", "_fields": {"kind": null, "value": 5143}}, {"_type": "Constant", "_fields": {"kind": null, "value": 103}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1744}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4638}}, {"_type": "Constant", "_fields": {"kind": null, "value": 7674}}, {"_type": "Constant", "_fields": {"kind": null, "value": 6963}}, {"_type": "Constant", "_fields": {"kind": null, "value": 102}}]}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "tensor", "value": {"_type": "Name", "_fields": {"id": "torch", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "input_ids", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2}}, {"_type": "Constant", "_fields": {"kind": null, "value": 20324}}, {"_type": "Constant", "_fields": {"kind": null, "value": 23690}}, {"_type": "Constant", "_fields": {"kind": null, "value": 8740}}, {"_type": "Constant", "_fields": {"kind": null, "value": 706}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}, {"_type": "Constant", "_fields": {"kind": null, "value": 10900}}, {"_type": "Constant", "_fields": {"kind": null, "value": 23343}}, {"_type": "Constant", "_fields": {"kind": null, "value": 20205}}, {"_type": "Constant", "_fields": {"kind": null, "value": 5850}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2}}]}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "tensor", "value": {"_type": "Name", "_fields": {"id": "torch", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "input_shape_ids", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2}}, {"_type": "Constant", "_fields": {"kind": null, "value": 718}}, {"_type": "Constant", "_fields": {"kind": null, "value": 397}}, {"_type": "Constant", "_fields": {"kind": null, "value": 52}}, {"_type": "Constant", "_fields": {"kind": null, "value": 61}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}, {"_type": "Constant", "_fields": {"kind": null, "value": 168}}, {"_type": "Constant", "_fields": {"kind": null, "value": 273}}, {"_type": "Constant", "_fields": {"kind": null, "value": 180}}, {"_type": "Constant", "_fields": {"kind": null, "value": 243}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2}}]}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "tensor", "value": {"_type": "Name", "_fields": {"id": "torch", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "input_pronunciation_ids", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "input_ids", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "input_shape_ids", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "input_pronunciation_ids", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "model", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "output", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "logits", "value": {"_type": "Name", "_fields": {"id": "output", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "argmax", "value": {"_type": "Name", "_fields": {"id": "torch", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "dim", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 2}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "output_ids", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 101}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2349}}, {"_type": "Constant", "_fields": {"kind": null, "value": 115}}, {"_type": "Constant", "_fields": {"kind": null, "value": 7944}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3221}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3791}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1744}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4638}}, {"_type": "Constant", "_fields": {"kind": null, "value": 7674}}, {"_type": "Constant", "_fields": {"kind": null, "value": 6963}}, {"_type": "Constant", "_fields": {"kind": null, "value": 102}}]}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "tensor", "value": {"_type": "Name", "_fields": {"id": "torch", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "expected_output", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "output_ids", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "expected_output", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "name": "test_inference_masked_lm", "returns": null, "type_params": [], "type_comment": null, "decorator_list": [{"_type": "Name", "_fields": {"id": "slow", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "name": "RoCBertModelIntegrationTest", "bases": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "TestCase", "value": {"_type": "Name", "_fields": {"id": "unittest", "ctx": {"_type": "Load", "_fields": {}}}}}}], "keywords": [], "type_params": [], "decorator_list": []}}], "type_ignores": []}}
class RoCBertModelIntegrationTest(unittest.TestCase): @slow def test_inference_masked_lm(self): model = RoCBertForMaskedLM.from_pretrained("weiweishi/roc-bert-base-zh") # input_text: ['[CLS]', 'b', 'a', '里', '系', '[MASK]', '国', '的', '首', '都', '[SEP]'] is the adversarial text # of ['[CLS]', '巴', '黎', '是', '[MASK]', '国', '的', '首', '都', '[SEP]'], means # "Paris is the [MASK] of France" in English input_ids = torch.tensor([[101, 144, 143, 7027, 5143, 103, 1744, 4638, 7674, 6963, 102]]) input_shape_ids = torch.tensor([[2, 20324, 23690, 8740, 706, 1, 10900, 23343, 20205, 5850, 2]]) input_pronunciation_ids = torch.tensor([[2, 718, 397, 52, 61, 1, 168, 273, 180, 243, 2]]) output = model(input_ids, input_shape_ids, input_pronunciation_ids) output_ids = torch.argmax(output.logits, dim=2) # convert to tokens is: ['[CLS]', '巴', '*', '黎', '是', '法', '国', '的', '首', '都', '[SEP]'] expected_output = torch.tensor([[101, 2349, 115, 7944, 3221, 3791, 1744, 4638, 7674, 6963, 102]]) self.assertEqual(output_ids, expected_output)
14,407
[ 0.01260901428759098, -0.016286643221974373, -0.023032942786812782, -0.006758240517228842, 0.008728398941457272, 0.022997122257947922, -0.008835862390697002, 0.03553449362516403, 0.01819710060954094, 0.029922528192400932, -0.015725446864962578, -0.013803048990666866, 0.03961809352040291, 0....
7
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "weiweishi/roc-bert-base-zh"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "from_pretrained", "value": {"_type": "Name", "_fields": {"id": "RoCBertForMaskedLM", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "model", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 101}}, {"_type": "Constant", "_fields": {"kind": null, "value": 144}}, {"_type": "Constant", "_fields": {"kind": null, "value": 143}}, {"_type": "Constant", "_fields": {"kind": null, "value": 7027}}, {"_type": "Constant", "_fields": {"kind": null, "value": 5143}}, {"_type": "Constant", "_fields": {"kind": null, "value": 103}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1744}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4638}}, {"_type": "Constant", "_fields": {"kind": null, "value": 7674}}, {"_type": "Constant", "_fields": {"kind": null, "value": 6963}}, {"_type": "Constant", "_fields": {"kind": null, "value": 102}}]}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "tensor", "value": {"_type": "Name", "_fields": {"id": "torch", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "input_ids", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2}}, {"_type": "Constant", "_fields": {"kind": null, "value": 20324}}, {"_type": "Constant", "_fields": {"kind": null, "value": 23690}}, {"_type": "Constant", "_fields": {"kind": null, "value": 8740}}, {"_type": "Constant", "_fields": {"kind": null, "value": 706}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}, {"_type": "Constant", "_fields": {"kind": null, "value": 10900}}, {"_type": "Constant", "_fields": {"kind": null, "value": 23343}}, {"_type": "Constant", "_fields": {"kind": null, "value": 20205}}, {"_type": "Constant", "_fields": {"kind": null, "value": 5850}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2}}]}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "tensor", "value": {"_type": "Name", "_fields": {"id": "torch", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "input_shape_ids", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2}}, {"_type": "Constant", "_fields": {"kind": null, "value": 718}}, {"_type": "Constant", "_fields": {"kind": null, "value": 397}}, {"_type": "Constant", "_fields": {"kind": null, "value": 52}}, {"_type": "Constant", "_fields": {"kind": null, "value": 61}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}, {"_type": "Constant", "_fields": {"kind": null, "value": 168}}, {"_type": "Constant", "_fields": {"kind": null, "value": 273}}, {"_type": "Constant", "_fields": {"kind": null, "value": 180}}, {"_type": "Constant", "_fields": {"kind": null, "value": 243}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2}}]}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "tensor", "value": {"_type": "Name", "_fields": {"id": "torch", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "input_pronunciation_ids", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "input_ids", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "input_shape_ids", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "input_pronunciation_ids", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "model", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "output", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "logits", "value": {"_type": "Name", "_fields": {"id": "output", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "argmax", "value": {"_type": "Name", "_fields": {"id": "torch", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "dim", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 2}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "output_ids", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 101}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2349}}, {"_type": "Constant", "_fields": {"kind": null, "value": 115}}, {"_type": "Constant", "_fields": {"kind": null, "value": 7944}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3221}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3791}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1744}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4638}}, {"_type": "Constant", "_fields": {"kind": null, "value": 7674}}, {"_type": "Constant", "_fields": {"kind": null, "value": 6963}}, {"_type": "Constant", "_fields": {"kind": null, "value": 102}}]}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "tensor", "value": {"_type": "Name", "_fields": {"id": "torch", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "expected_output", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "output_ids", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "expected_output", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "name": "test_inference_masked_lm", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def test_inference_masked_lm(self): model = RoCBertForMaskedLM.from_pretrained("weiweishi/roc-bert-base-zh") # input_text: ['[CLS]', 'b', 'a', '里', '系', '[MASK]', '国', '的', '首', '都', '[SEP]'] is the adversarial text # of ['[CLS]', '巴', '黎', '是', '[MASK]', '国', '的', '首', '都', '[SEP]'], means # "Paris is the [MASK] of France" in English input_ids = torch.tensor([[101, 144, 143, 7027, 5143, 103, 1744, 4638, 7674, 6963, 102]]) input_shape_ids = torch.tensor([[2, 20324, 23690, 8740, 706, 1, 10900, 23343, 20205, 5850, 2]]) input_pronunciation_ids = torch.tensor([[2, 718, 397, 52, 61, 1, 168, 273, 180, 243, 2]]) output = model(input_ids, input_shape_ids, input_pronunciation_ids) output_ids = torch.argmax(output.logits, dim=2) # convert to tokens is: ['[CLS]', '巴', '*', '黎', '是', '法', '国', '的', '首', '都', '[SEP]'] expected_output = torch.tensor([[101, 2349, 115, 7944, 3221, 3791, 1744, 4638, 7674, 6963, 102]]) self.assertEqual(output_ids, expected_output)
14,408
[ 0.06294901669025421, 0.06272032111883163, 0.004134424030780792, -0.0458252839744091, -0.05820354446768761, 0.027458008378744125, 0.06723710149526596, -0.027858229354023933, -0.021097354590892792, -0.011770780198276043, 0.015222685411572456, -0.006921676453202963, -0.011191889643669128, -0....
11
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "replay", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "log", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [{"_type": "Constant", "_fields": {"kind": null, "value": null}}], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "StringIO", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "log", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}], "test": {"_type": "UnaryOp", "_fields": {"op": {"_type": "Not", "_fields": {}}, "operand": {"_type": "Name", "_fields": {"id": "replay", "ctx": {"_type": "Load", "_fields": {}}}}}}, "orelse": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "log", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "StringIO", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "log", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}]}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "Record", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "replay", "value": {"_type": "Name", "_fields": {"id": "replay", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "file_object", "value": {"_type": "Name", "_fields": {"id": "log", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "record", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "disturb_mem", "value": {"_type": "Name", "_fields": {"id": "disturb_mem", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "RecordMode", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "record", "value": {"_type": "Name", "_fields": {"id": "record", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "mode", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "zeros", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Name", "_fields": {"id": "sharedX", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "name", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "b"}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "b", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "OrderedDict", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "channels", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "disturb_mem", "value": {"_type": "Name", "_fields": {"id": "disturb_mem", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "max", "value": {"_type": "Name", "_fields": {"id": "b", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "axis", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "v_max", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "min", "value": {"_type": "Name", "_fields": {"id": "b", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "axis", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "v_min", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Sub", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "v_max", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "Name", "_fields": {"id": "v_min", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "v_range", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": []}}, "targets": [{"_type": "Name", "_fields": {"id": "updates", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "For", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "disturb_mem", "value": {"_type": "Name", "_fields": {"id": "disturb_mem", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 0.0}}], "func": {"_type": "Name", "_fields": {"id": "sharedX", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "name", "value": {"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "Constant", "_fields": {"kind": null, "value": "s_"}}, "right": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "i", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "str", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "s", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "s", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "val", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "append", "value": {"_type": "Name", "_fields": {"id": "updates", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "iter": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "max", "value": {"_type": "Name", "_fields": {"id": "v_max", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "min", "value": {"_type": "Name", "_fields": {"id": "v_max", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "max", "value": {"_type": "Name", "_fields": {"id": "v_range", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}]}}], "func": {"_type": "Name", "_fields": {"id": "enumerate", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "orelse": [], "target": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "i", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "val", "ctx": {"_type": "Store", "_fields": {}}}}]}}, "type_comment": null}}, {"_type": "For", "_fields": {"body": [{"_type": "If", "_fields": {"body": [{"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": null}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "name", "value": {"_type": "Name", "_fields": {"id": "var", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}], "test": {"_type": "BoolOp", "_fields": {"op": {"_type": "Or", "_fields": {}}, "values": [{"_type": "Compare", "_fields": {"ops": [{"_type": "NotEq", "_fields": {}}], "left": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "name", "value": {"_type": "Name", "_fields": {"id": "var", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": "s"}}]}}, {"_type": "Compare", "_fields": {"ops": [{"_type": "NotEq", "_fields": {}}], "left": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "name", "value": {"_type": "Name", "_fields": {"id": "var", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Name", "_fields": {"id": "len", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": 2}}]}}]}}, "orelse": []}}], "test": {"_type": "BoolOp", "_fields": {"op": {"_type": "And", "_fields": {}}, "values": [{"_type": "Compare", "_fields": {"ops": [{"_type": "IsNot", "_fields": {}}], "left": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "name", "value": {"_type": "Name", "_fields": {"id": "var", "ctx": {"_type": "Load", "_fields": {}}}}}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": null}}]}}, {"_type": "Compare", "_fields": {"ops": [{"_type": "IsNot", "_fields": {}}], "left": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "name", "value": {"_type": "Name", "_fields": {"id": "var", "ctx": {"_type": "Load", "_fields": {}}}}}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": "b"}}]}}]}}, "orelse": []}}], "iter": {"_type": "Call", "_fields": {"args": [{"_type": "GeneratorExp", "_fields": {"elt": {"_type": "Name", "_fields": {"id": "update", "ctx": {"_type": "Load", "_fields": {}}}}, "generators": [{"_type": "comprehension", "_fields": {"ifs": [], "iter": {"_type": "Name", "_fields": {"id": "updates", "ctx": {"_type": "Load", "_fields": {}}}}, "target": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "_", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "update", "ctx": {"_type": "Store", "_fields": {}}}}]}}, "is_async": 0}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "ancestors", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "graph", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "gof", "value": {"_type": "Name", "_fields": {"id": "theano", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": []}}, "orelse": [], "target": {"_type": "Name", "_fields": {"id": "var", "ctx": {"_type": "Store", "_fields": {}}}}, "type_comment": null}}, {"_type": "For", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "s", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Name", "_fields": {"id": "key", "ctx": {"_type": "Load", "_fields": {}}}}, "value": {"_type": "Name", "_fields": {"id": "channels", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "append", "value": {"_type": "Name", "_fields": {"id": "updates", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "iter": {"_type": "Name", "_fields": {"id": "channels", "ctx": {"_type": "Load", "_fields": {}}}}, "orelse": [], "target": {"_type": "Name", "_fields": {"id": "key", "ctx": {"_type": "Store", "_fields": {}}}}, "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "function", "value": {"_type": "Name", "_fields": {"id": "theano", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "mode", "value": {"_type": "Name", "_fields": {"id": "mode", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "updates", "value": {"_type": "Name", "_fields": {"id": "updates", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "on_unused_input", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "ignore"}}}}, {"_type": "keyword", "_fields": {"arg": "name", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "f"}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "f", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "For", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "output", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "var_descriptor", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": "\n"}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "handle_line", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "record", "value": {"_type": "Name", "_fields": {"id": "mode", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}], "iter": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "outputs", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "fgraph", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "maker", "value": {"_type": "Name", "_fields": {"id": "f", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "orelse": [], "target": {"_type": "Name", "_fields": {"id": "output", "ctx": {"_type": "Store", "_fields": {}}}}, "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "disturb_mem", "value": {"_type": "Name", "_fields": {"id": "disturb_mem", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "f", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "flush", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "f", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "record", "value": {"_type": "Name", "_fields": {"id": "mode", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": []}}}}, {"_type": "If", "_fields": {"body": [{"_type": "Return", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "getvalue", "value": {"_type": "Name", "_fields": {"id": "log", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "test": {"_type": "UnaryOp", "_fields": {"op": {"_type": "Not", "_fields": {}}, "operand": {"_type": "Name", "_fields": {"id": "replay", "ctx": {"_type": "Load", "_fields": {}}}}}}, "orelse": []}}], "name": "run", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def run(replay, log=None): if not replay: log = StringIO() else: log = StringIO(log) record = Record(replay=replay, file_object=log) disturb_mem.disturb_mem() mode = RecordMode(record=record) b = sharedX(np.zeros((2,)), name='b') channels = OrderedDict() disturb_mem.disturb_mem() v_max = b.max(axis=0) v_min = b.min(axis=0) v_range = v_max - v_min updates = [] for i, val in enumerate([ v_max.max(), v_max.min(), v_range.max(), ]): disturb_mem.disturb_mem() s = sharedX(0., name='s_' + str(i)) updates.append((s, val)) for var in theano.gof.graph.ancestors(update for _, update in updates): if var.name is not None and var.name is not 'b': if var.name[0] != 's' or len(var.name) != 2: var.name = None for key in channels: updates.append((s, channels[key])) f = theano.function([], mode=mode, updates=updates, on_unused_input='ignore', name='f') for output in f.maker.fgraph.outputs: mode.record.handle_line(var_descriptor(output) + '\n') disturb_mem.disturb_mem() f() mode.record.f.flush() if not replay: return log.getvalue()
14,409
[ -0.010341956280171871, -0.002737282309681177, 0.024340294301509857, -0.04091411083936691, 0.012443708255887032, 0.017988331615924835, 0.020150134339928627, -0.03827190771698952, 0.023299425840377808, 0.005808176007121801, 0.022538792341947556, -0.040673911571502686, 0.0006943289190530777, ...
13
{"_type": "Module", "_fields": {"body": [{"_type": "ClassDef", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "method", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "static_stop", "value": {"_type": "Name", "_fields": {"id": "MockMonitor", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "name": "teardown_method", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "With", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "foo"}}, {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "fsEventHappened", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "MockMonitor", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "ApiUsageException", "value": {"_type": "Name", "_fields": {"id": "omero", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "raises", "value": {"_type": "Name", "_fields": {"id": "pytest", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "name": "testBadId", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "With", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": ""}}, {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "EventInfo", "value": {"_type": "Name", "_fields": {"id": "monitors", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "fsEventHappened", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "MockMonitor", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "ApiUsageException", "value": {"_type": "Name", "_fields": {"id": "omero", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "raises", "value": {"_type": "Name", "_fields": {"id": "pytest", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "name": "testBadFileId", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": ""}}, {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "fsEventHappened", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "MockMonitor", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, "keywords": []}}}}], "name": "testEmptyAdd", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}, {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Div", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Div", "_fields": {}}, "left": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "dir", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": "root"}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": "dirtimeout"}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "Create", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "EventType", "value": {"_type": "Name", "_fields": {"id": "monitors", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "EventInfo", "value": {"_type": "Name", "_fields": {"id": "monitors", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Name", "_fields": {"id": "DirInfoEvent", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "add", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "driver", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "run", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "driver", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}], "name": "testBasicAdd", "returns": null, "type_params": [], "type_comment": null, "decorator_list": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "broken", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mark", "value": {"_type": "Name", "_fields": {"id": "pytest", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "ticket", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "12566"}}}}]}}, {"_type": "Name", "_fields": {"id": "with_driver", "ctx": {"_type": "Load", "_fields": {}}}}]}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Div", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Div", "_fields": {}}, "left": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "dir", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": "root"}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": "file"}}}}, "targets": [{"_type": "Name", "_fields": {"id": "f", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Dict", "_fields": {"keys": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "f", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "str", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}], "values": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "f", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "str", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}]}}]}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "files", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "client", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 0}}, {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Div", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Div", "_fields": {}}, "left": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "dir", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": "root"}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": "file"}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "Create", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "EventType", "value": {"_type": "Name", "_fields": {"id": "monitors", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "EventInfo", "value": {"_type": "Name", "_fields": {"id": "monitors", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Name", "_fields": {"id": "DirInfoEvent", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "add", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "driver", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "run", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "driver", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 0.25}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sleep", "value": {"_type": "Name", "_fields": {"id": "time", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "name": "testWithSingleImport", "returns": null, "type_params": [], "type_comment": null, "decorator_list": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "broken", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mark", "value": {"_type": "Name", "_fields": {"id": "pytest", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "ticket", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "12566"}}}}]}}, {"_type": "Name", "_fields": {"id": "with_driver", "ctx": {"_type": "Load", "_fields": {}}}}]}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Div", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Div", "_fields": {}}, "left": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "dir", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": "root"}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": "file1"}}}}], "func": {"_type": "Name", "_fields": {"id": "str", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "f1", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Div", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Div", "_fields": {}}, "left": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "dir", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": "root"}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": "file2"}}}}], "func": {"_type": "Name", "_fields": {"id": "str", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "f2", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Div", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Div", "_fields": {}}, "left": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "dir", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": "root"}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": "file3"}}}}], "func": {"_type": "Name", "_fields": {"id": "str", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "f3", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Div", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Div", "_fields": {}}, "left": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "dir", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": "root"}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": "file4"}}}}], "func": {"_type": "Name", "_fields": {"id": "str", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "f4", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Dict", "_fields": {"keys": [{"_type": "Name", "_fields": {"id": "f1", "ctx": {"_type": "Load", "_fields": {}}}}], "values": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "f1", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "f2", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "f3", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "f4", "ctx": {"_type": "Load", "_fields": {}}}}]}}]}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "files", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "client", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "setDirImportWait", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "client", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 0.0}}, {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "f1", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "Create", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "EventType", "value": {"_type": "Name", "_fields": {"id": "monitors", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "EventInfo", "value": {"_type": "Name", "_fields": {"id": "monitors", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Name", "_fields": {"id": "DirInfoEvent", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "add", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "driver", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 100}}, {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "f2", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "Create", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "EventType", "value": {"_type": "Name", "_fields": {"id": "monitors", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "EventInfo", "value": {"_type": "Name", "_fields": {"id": "monitors", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Name", "_fields": {"id": "DirInfoEvent", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "add", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "driver", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 200}}, {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "f3", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "Create", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "EventType", "value": {"_type": "Name", "_fields": {"id": "monitors", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "EventInfo", "value": {"_type": "Name", "_fields": {"id": "monitors", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Name", "_fields": {"id": "DirInfoEvent", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "add", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "driver", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 300}}, {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "f4", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "Create", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "EventType", "value": {"_type": "Name", "_fields": {"id": "monitors", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "EventInfo", "value": {"_type": "Name", "_fields": {"id": "monitors", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Name", "_fields": {"id": "DirInfoEvent", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "add", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "driver", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sleep", "value": {"_type": "Name", "_fields": {"id": "time", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "run", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "driver", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}], "name": "testWithMultiImport", "returns": null, "type_params": [], "type_comment": null, "decorator_list": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "broken", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mark", "value": {"_type": "Name", "_fields": {"id": "pytest", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "ticket", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "12566"}}}}]}}, {"_type": "Name", "_fields": {"id": "with_driver", "ctx": {"_type": "Load", "_fields": {}}}}]}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}, {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Div", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Div", "_fields": {}}, "left": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "dir", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": "root"}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": "dir"}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "Create", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "EventType", "value": {"_type": "Name", "_fields": {"id": "monitors", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "EventInfo", "value": {"_type": "Name", "_fields": {"id": "monitors", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Name", "_fields": {"id": "DirInfoEvent", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "add", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "driver", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}, {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Div", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Div", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Div", "_fields": {}}, "left": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "dir", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": "root"}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": "dir"}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": "dir"}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "Create", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "EventType", "value": {"_type": "Name", "_fields": {"id": "monitors", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "EventInfo", "value": {"_type": "Name", "_fields": {"id": "monitors", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Name", "_fields": {"id": "DirInfoEvent", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "add", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "driver", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "run", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "driver", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}], "name": "testDirectoryInDirectory", "returns": null, "type_params": [], "type_comment": null, "decorator_list": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "broken", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mark", "value": {"_type": "Name", "_fields": {"id": "pytest", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "ticket", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "12566"}}}}]}}, {"_type": "Name", "_fields": {"id": "with_driver", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "name": "TestMonitor", "bases": [{"_type": "Name", "_fields": {"id": "object", "ctx": {"_type": "Load", "_fields": {}}}}], "keywords": [], "type_params": [], "decorator_list": []}}], "type_ignores": []}}
class TestMonitor(object): def teardown_method(self, method): MockMonitor.static_stop() def testBadId(self): with pytest.raises(omero.ApiUsageException): MockMonitor().fsEventHappened('foo', []) def testBadFileId(self): # Could cause infinite loop with pytest.raises(omero.ApiUsageException): MockMonitor().fsEventHappened('', [monitors.EventInfo()]) def testEmptyAdd(self): MockMonitor().fsEventHappened('', []) # Does nothing. @pytest.mark.broken(ticket="12566") @with_driver def testBasicAdd(self): self.driver.add(DirInfoEvent(1, monitors.EventInfo( self.dir / "root" / "dirtimeout", monitors.EventType.Create))) self.driver.run() @pytest.mark.broken(ticket="12566") @with_driver def testWithSingleImport(self): f = self.dir / "root" / "file" self.client.files = {str(f): [str(f)]} self.driver.add(DirInfoEvent(0, monitors.EventInfo( self.dir / "root" / "file", monitors.EventType.Create))) self.driver.run() time.sleep(0.25) @pytest.mark.broken(ticket="12566") @with_driver def testWithMultiImport(self): f1 = str(self.dir / "root" / "file1") f2 = str(self.dir / "root" / "file2") f3 = str(self.dir / "root" / "file3") f4 = str(self.dir / "root" / "file4") self.client.files = {f1: [f1, f2, f3, f4]} self.client.setDirImportWait(1) self.driver.add(DirInfoEvent(0.0, monitors.EventInfo( f1, monitors.EventType.Create))) self.driver.add(DirInfoEvent(100, monitors.EventInfo( f2, monitors.EventType.Create))) self.driver.add(DirInfoEvent(200, monitors.EventInfo( f3, monitors.EventType.Create))) self.driver.add(DirInfoEvent(300, monitors.EventInfo( f4, monitors.EventType.Create))) time.sleep(1) self.driver.run() @pytest.mark.broken(ticket="12566") @with_driver def testDirectoryInDirectory(self): self.driver.add(DirInfoEvent(1, monitors.EventInfo( self.dir / "root" / "dir", monitors.EventType.Create))) self.driver.add(DirInfoEvent(1, monitors.EventInfo( self.dir / "root" / "dir" / "dir", monitors.EventType.Create))) self.driver.run()
14,410
[ 0.0030340931843966246, -0.025190917775034904, 0.04383690655231476, -0.07637321203947067, 0.01677432656288147, -0.040493812412023544, 0.0052853841334581375, 0.014996835961937904, -0.006603787653148174, 0.04148261621594429, 0.0011101955315098166, 0.006756816525012255, -0.01591501012444496, -...
10
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Div", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Div", "_fields": {}}, "left": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "dir", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": "root"}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": "file1"}}}}], "func": {"_type": "Name", "_fields": {"id": "str", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "f1", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Div", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Div", "_fields": {}}, "left": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "dir", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": "root"}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": "file2"}}}}], "func": {"_type": "Name", "_fields": {"id": "str", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "f2", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Div", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Div", "_fields": {}}, "left": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "dir", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": "root"}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": "file3"}}}}], "func": {"_type": "Name", "_fields": {"id": "str", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "f3", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Div", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Div", "_fields": {}}, "left": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "dir", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": "root"}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": "file4"}}}}], "func": {"_type": "Name", "_fields": {"id": "str", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "f4", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Dict", "_fields": {"keys": [{"_type": "Name", "_fields": {"id": "f1", "ctx": {"_type": "Load", "_fields": {}}}}], "values": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "f1", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "f2", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "f3", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "f4", "ctx": {"_type": "Load", "_fields": {}}}}]}}]}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "files", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "client", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "setDirImportWait", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "client", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 0.0}}, {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "f1", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "Create", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "EventType", "value": {"_type": "Name", "_fields": {"id": "monitors", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "EventInfo", "value": {"_type": "Name", "_fields": {"id": "monitors", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Name", "_fields": {"id": "DirInfoEvent", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "add", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "driver", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 100}}, {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "f2", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "Create", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "EventType", "value": {"_type": "Name", "_fields": {"id": "monitors", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "EventInfo", "value": {"_type": "Name", "_fields": {"id": "monitors", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Name", "_fields": {"id": "DirInfoEvent", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "add", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "driver", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 200}}, {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "f3", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "Create", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "EventType", "value": {"_type": "Name", "_fields": {"id": "monitors", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "EventInfo", "value": {"_type": "Name", "_fields": {"id": "monitors", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Name", "_fields": {"id": "DirInfoEvent", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "add", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "driver", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 300}}, {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "f4", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "Create", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "EventType", "value": {"_type": "Name", "_fields": {"id": "monitors", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "EventInfo", "value": {"_type": "Name", "_fields": {"id": "monitors", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Name", "_fields": {"id": "DirInfoEvent", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "add", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "driver", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sleep", "value": {"_type": "Name", "_fields": {"id": "time", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "run", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "driver", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}], "name": "testWithMultiImport", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def testWithMultiImport(self): f1 = str(self.dir / "root" / "file1") f2 = str(self.dir / "root" / "file2") f3 = str(self.dir / "root" / "file3") f4 = str(self.dir / "root" / "file4") self.client.files = {f1: [f1, f2, f3, f4]} self.client.setDirImportWait(1) self.driver.add(DirInfoEvent(0.0, monitors.EventInfo( f1, monitors.EventType.Create))) self.driver.add(DirInfoEvent(100, monitors.EventInfo( f2, monitors.EventType.Create))) self.driver.add(DirInfoEvent(200, monitors.EventInfo( f3, monitors.EventType.Create))) self.driver.add(DirInfoEvent(300, monitors.EventInfo( f4, monitors.EventType.Create))) time.sleep(1) self.driver.run()
14,411
[ -0.017283275723457336, -0.0030693532899022102, 0.03027242235839367, -0.019133783876895905, -0.0061861551366746426, -0.009222887456417084, 0.03361757472157478, 0.044269859790802, -0.0013804675545543432, 0.08080554008483887, -0.01013627927750349, -0.04472062364220619, 0.05176679044961929, 0....
13
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "module", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "candidate", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "prefix", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "list", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "commands", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "set_route"}}, {"_type": "Name", "_fields": {"id": "module", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "commands", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "prefix", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "invoke", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "If", "_fields": {"body": [{"_type": "If", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "commands", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "add", "value": {"_type": "Name", "_fields": {"id": "candidate", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "parents", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": []}}}}]}}}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "vrf"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "params", "value": {"_type": "Name", "_fields": {"id": "module", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": "default"}}]}}, "orelse": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "commands", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "add", "value": {"_type": "Name", "_fields": {"id": "candidate", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "parents", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "vrf"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "params", "value": {"_type": "Name", "_fields": {"id": "module", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "format", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "vrf context {0}"}}}}, "keywords": []}}]}}}}]}}}}]}}], "test": {"_type": "Name", "_fields": {"id": "commands", "ctx": {"_type": "Load", "_fields": {}}}}, "orelse": []}}], "name": "state_present", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def state_present(module, candidate, prefix): commands = list() invoke('set_route', module, commands, prefix) if commands: if module.params['vrf'] == 'default': candidate.add(commands, parents=[]) else: candidate.add(commands, parents=['vrf context {0}'.format(module.params['vrf'])])
14,412
[ -0.029374094679951668, 0.025416718795895576, 0.019492432475090027, -0.02473360113799572, -0.05662816762924194, -0.007708638906478882, 0.011807349510490894, 0.028455419465899467, 0.004083988722413778, 0.06840607523918152, -0.009775660932064056, -0.0060126204043626785, 0.04426136612892151, 0...
10
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "module", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "prefix", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "warnings", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": "tag"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "pref"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "route_name"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "next_hop"}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "key_map", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "module", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "get_config", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "netcfg", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "vrf"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "params", "value": {"_type": "Name", "_fields": {"id": "module", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "format", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "vrf context {0}"}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "parents", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "prefix", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "fix_prefix_to_regex", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "prefix_to_regex", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "prefix_to_regex", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "format", "value": {"_type": "Constant", "_fields": {"kind": null, "value": ".*ip\\sroute\\s{0}\\s(?P<next_hop>\\S+)(\\sname\\s(?P<route_name>\\S+))?(\\stag\\s(?P<tag>\\d+))?(\\s(?P<pref>\\d+)).*"}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "route_regex", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "netcfg", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "str", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "config", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "vrf"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "params", "value": {"_type": "Name", "_fields": {"id": "module", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": "default"}}]}}, "orelse": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "parents", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_section", "value": {"_type": "Name", "_fields": {"id": "netcfg", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "config", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}]}}, {"_type": "If", "_fields": {"body": [{"_type": "Try", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "route_regex", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "config", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "DOTALL", "value": {"_type": "Name", "_fields": {"id": "re", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "match", "value": {"_type": "Name", "_fields": {"id": "re", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "match_route", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "groupdict", "value": {"_type": "Name", "_fields": {"id": "match_route", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "group_route", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "For", "_fields": {"body": [{"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": ""}}, "targets": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "slice": {"_type": "Name", "_fields": {"id": "key", "ctx": {"_type": "Load", "_fields": {}}}}, "value": {"_type": "Name", "_fields": {"id": "group_route", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "NotIn", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "key", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "Name", "_fields": {"id": "group_route", "ctx": {"_type": "Load", "_fields": {}}}}]}}, "orelse": []}}], "iter": {"_type": "Name", "_fields": {"id": "key_map", "ctx": {"_type": "Load", "_fields": {}}}}, "orelse": [], "target": {"_type": "Name", "_fields": {"id": "key", "ctx": {"_type": "Store", "_fields": {}}}}, "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Name", "_fields": {"id": "prefix", "ctx": {"_type": "Load", "_fields": {}}}}, "targets": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "prefix"}}, "value": {"_type": "Name", "_fields": {"id": "group_route", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "vrf"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "params", "value": {"_type": "Name", "_fields": {"id": "module", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "targets": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "vrf"}}, "value": {"_type": "Name", "_fields": {"id": "group_route", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}], "orelse": [], "handlers": [{"_type": "ExceptHandler", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Dict", "_fields": {"keys": [], "values": []}}, "targets": [{"_type": "Name", "_fields": {"id": "group_route", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}], "name": null, "type": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "AttributeError", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "TypeError", "ctx": {"_type": "Load", "_fields": {}}}}]}}}}], "finalbody": []}}], "test": {"_type": "Name", "_fields": {"id": "config", "ctx": {"_type": "Load", "_fields": {}}}}, "orelse": [{"_type": "Assign", "_fields": {"value": {"_type": "Dict", "_fields": {"keys": [], "values": []}}, "targets": [{"_type": "Name", "_fields": {"id": "group_route", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "vrf"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "params", "value": {"_type": "Name", "_fields": {"id": "module", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "format", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "VRF {0} didn't exist."}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "msg", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "If", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "msg", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "append", "value": {"_type": "Name", "_fields": {"id": "warnings", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "NotIn", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "msg", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "Name", "_fields": {"id": "warnings", "ctx": {"_type": "Load", "_fields": {}}}}]}}, "orelse": []}}]}}, {"_type": "Return", "_fields": {"value": {"_type": "Name", "_fields": {"id": "group_route", "ctx": {"_type": "Load", "_fields": {}}}}}}], "name": "get_existing", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def get_existing(module, prefix, warnings): key_map = ['tag', 'pref', 'route_name', 'next_hop'] netcfg = get_config(module) parents = 'vrf context {0}'.format(module.params['vrf']) prefix_to_regex = fix_prefix_to_regex(prefix) route_regex = ('.*ip\sroute\s{0}\s(?P<next_hop>\S+)(\sname\s(?P<route_name>\S+))?' '(\stag\s(?P<tag>\d+))?(\s(?P<pref>\d+)).*'.format(prefix_to_regex)) if module.params['vrf'] == 'default': config = str(netcfg) else: config = netcfg.get_section(parents) if config: try: match_route = re.match(route_regex, config, re.DOTALL) group_route = match_route.groupdict() for key in key_map: if key not in group_route: group_route[key] = '' group_route['prefix'] = prefix group_route['vrf'] = module.params['vrf'] except (AttributeError, TypeError): group_route = {} else: group_route = {} msg = ("VRF {0} didn't exist.".format(module.params['vrf'])) if msg not in warnings: warnings.append(msg) return group_route
14,413
[ -0.004497994668781757, 0.01688535511493683, 0.04078347608447075, -0.03954007849097252, 0.001141595421358943, -0.007025202736258507, -0.0025551842991262674, 0.03697867691516876, -0.0039850929751992226, 0.11210482567548752, 0.01668640971183777, -0.04687613248825073, 0.05779317021369934, 0.04...
10
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "module", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "candidate", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "prefix", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "module", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "get_config", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "netcfg", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "list", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "commands", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "vrf"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "params", "value": {"_type": "Name", "_fields": {"id": "module", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "format", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "vrf context {0}"}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "parents", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "set_route"}}, {"_type": "Name", "_fields": {"id": "module", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "commands", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "prefix", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "invoke", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "commands", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_section", "value": {"_type": "Name", "_fields": {"id": "netcfg", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "config", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "If", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "remove_route"}}, {"_type": "Name", "_fields": {"id": "module", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "commands", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "config", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "prefix", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "invoke", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "commands", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "add", "value": {"_type": "Name", "_fields": {"id": "candidate", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "parents", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": []}}}}]}}}}], "test": {"_type": "Name", "_fields": {"id": "config", "ctx": {"_type": "Load", "_fields": {}}}}, "orelse": []}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "vrf"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "params", "value": {"_type": "Name", "_fields": {"id": "module", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": "default"}}]}}, "orelse": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "parents", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_section", "value": {"_type": "Name", "_fields": {"id": "netcfg", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "config", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "\n"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "split", "value": {"_type": "Name", "_fields": {"id": "config", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "splitted_config", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "strip", "value": {"_type": "Name", "_fields": {"id": "str", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Name", "_fields": {"id": "splitted_config", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "map", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "splitted_config", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "If", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "remove_route"}}, {"_type": "Name", "_fields": {"id": "module", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "commands", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "config", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "prefix", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "invoke", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "commands", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "add", "value": {"_type": "Name", "_fields": {"id": "candidate", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "parents", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "parents", "ctx": {"_type": "Load", "_fields": {}}}}]}}}}]}}}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "In", "_fields": {}}], "left": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "commands", "ctx": {"_type": "Load", "_fields": {}}}}}}, "comparators": [{"_type": "Name", "_fields": {"id": "splitted_config", "ctx": {"_type": "Load", "_fields": {}}}}]}}, "orelse": []}}]}}], "name": "state_absent", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def state_absent(module, candidate, prefix): netcfg = get_config(module) commands = list() parents = 'vrf context {0}'.format(module.params['vrf']) invoke('set_route', module, commands, prefix) if module.params['vrf'] == 'default': config = netcfg.get_section(commands[0]) if config: invoke('remove_route', module, commands, config, prefix) candidate.add(commands, parents=[]) else: config = netcfg.get_section(parents) splitted_config = config.split('\n') splitted_config = map(str.strip, splitted_config) if commands[0] in splitted_config: invoke('remove_route', module, commands, config, prefix) candidate.add(commands, parents=[parents])
14,414
[ -0.006252343766391277, -0.019958507269620895, -0.0002907091984525323, 0.011583167128264904, -0.009920929558575153, -0.019141970202326775, -0.004776744171977043, 0.05197843909263611, 0.01414942741394043, 0.03228822350502014, 0.0156541895121336, -0.04292653873562813, 0.05048534274101257, 0.0...
10
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "address", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "mask", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "module", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "."}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "split", "value": {"_type": "Name", "_fields": {"id": "address", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "octects", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "If", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "fail_json", "value": {"_type": "Name", "_fields": {"id": "module", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "msg", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "Incorrect address format."}}}}, {"_type": "keyword", "_fields": {"arg": "address", "value": {"_type": "Name", "_fields": {"id": "address", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Gt", "_fields": {}}], "left": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "octects", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "len", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": 4}}]}}, "orelse": []}}, {"_type": "For", "_fields": {"body": [{"_type": "Try", "_fields": {"body": [{"_type": "If", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "fail_json", "value": {"_type": "Name", "_fields": {"id": "module", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "msg", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "Address may contain invalid values."}}}}, {"_type": "keyword", "_fields": {"arg": "address", "value": {"_type": "Name", "_fields": {"id": "address", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}}}], "test": {"_type": "BoolOp", "_fields": {"op": {"_type": "Or", "_fields": {}}, "values": [{"_type": "Compare", "_fields": {"ops": [{"_type": "Lt", "_fields": {}}], "left": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "octect", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "int", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": 0}}]}}, {"_type": "Compare", "_fields": {"ops": [{"_type": "Gt", "_fields": {}}], "left": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "octect", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "int", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": 255}}]}}]}}, "orelse": []}}], "orelse": [], "handlers": [{"_type": "ExceptHandler", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "fail_json", "value": {"_type": "Name", "_fields": {"id": "module", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "msg", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "Address may contain non-integer values."}}}}, {"_type": "keyword", "_fields": {"arg": "address", "value": {"_type": "Name", "_fields": {"id": "address", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}}}], "name": null, "type": {"_type": "Name", "_fields": {"id": "ValueError", "ctx": {"_type": "Load", "_fields": {}}}}}}], "finalbody": []}}], "iter": {"_type": "Name", "_fields": {"id": "octects", "ctx": {"_type": "Load", "_fields": {}}}}, "orelse": [], "target": {"_type": "Name", "_fields": {"id": "octect", "ctx": {"_type": "Store", "_fields": {}}}}, "type_comment": null}}, {"_type": "Try", "_fields": {"body": [{"_type": "If", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "fail_json", "value": {"_type": "Name", "_fields": {"id": "module", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "msg", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "Incorrect mask value."}}}}, {"_type": "keyword", "_fields": {"arg": "mask", "value": {"_type": "Name", "_fields": {"id": "mask", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}}}], "test": {"_type": "BoolOp", "_fields": {"op": {"_type": "Or", "_fields": {}}, "values": [{"_type": "Compare", "_fields": {"ops": [{"_type": "Lt", "_fields": {}}], "left": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "mask", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "int", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": 0}}]}}, {"_type": "Compare", "_fields": {"ops": [{"_type": "Gt", "_fields": {}}], "left": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "mask", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "int", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": 32}}]}}]}}, "orelse": []}}], "orelse": [], "handlers": [{"_type": "ExceptHandler", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "fail_json", "value": {"_type": "Name", "_fields": {"id": "module", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "msg", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "Mask may contain non-integer values."}}}}, {"_type": "keyword", "_fields": {"arg": "mask", "value": {"_type": "Name", "_fields": {"id": "mask", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}}}], "name": null, "type": {"_type": "Name", "_fields": {"id": "ValueError", "ctx": {"_type": "Load", "_fields": {}}}}}}], "finalbody": []}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "mask", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "int", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}], "func": {"_type": "Name", "_fields": {"id": "get_dotted_mask", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "netmask", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Return", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "address", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "netmask", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "get_network_start", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "join", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "."}}}}, "keywords": []}}}}], "name": "network_from_string", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def network_from_string(address, mask, module): octects = address.split('.') if len(octects) > 4: module.fail_json(msg='Incorrect address format.', address=address) for octect in octects: try: if int(octect) < 0 or int(octect) > 255: module.fail_json(msg='Address may contain invalid values.', address=address) except ValueError: module.fail_json(msg='Address may contain non-integer values.', address=address) try: if int(mask) < 0 or int(mask) > 32: module.fail_json(msg='Incorrect mask value.', mask=mask) except ValueError: module.fail_json(msg='Mask may contain non-integer values.', mask=mask) netmask = get_dotted_mask(int(mask)) return '.'.join(get_network_start(address, netmask))
14,415
[ -0.020362965762615204, -0.03609974682331085, 0.008255518041551113, -0.0037599869538098574, -0.030467024073004723, -0.012252621352672577, 0.008913637138903141, 0.03933227062225342, 0.021195292472839355, 0.02889915369451046, -0.025260142982006073, -0.05408187210559845, 0.014604427851736546, ...
9
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "module", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "commands", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "prefix", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "prefix", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "next_hop"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "params", "value": {"_type": "Name", "_fields": {"id": "module", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "format", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "ip route {0} {1}"}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "route_cmd", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "If", "_fields": {"body": [{"_type": "AugAssign", "_fields": {"op": {"_type": "Add", "_fields": {}}, "value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "route_name"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "params", "value": {"_type": "Name", "_fields": {"id": "module", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "format", "value": {"_type": "Constant", "_fields": {"kind": null, "value": " name {0}"}}}}, "keywords": []}}, "target": {"_type": "Name", "_fields": {"id": "route_cmd", "ctx": {"_type": "Store", "_fields": {}}}}}}], "test": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "route_name"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "params", "value": {"_type": "Name", "_fields": {"id": "module", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "orelse": []}}, {"_type": "If", "_fields": {"body": [{"_type": "AugAssign", "_fields": {"op": {"_type": "Add", "_fields": {}}, "value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "tag"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "params", "value": {"_type": "Name", "_fields": {"id": "module", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "format", "value": {"_type": "Constant", "_fields": {"kind": null, "value": " tag {0}"}}}}, "keywords": []}}, "target": {"_type": "Name", "_fields": {"id": "route_cmd", "ctx": {"_type": "Store", "_fields": {}}}}}}], "test": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "tag"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "params", "value": {"_type": "Name", "_fields": {"id": "module", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "orelse": []}}, {"_type": "If", "_fields": {"body": [{"_type": "AugAssign", "_fields": {"op": {"_type": "Add", "_fields": {}}, "value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "pref"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "params", "value": {"_type": "Name", "_fields": {"id": "module", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "format", "value": {"_type": "Constant", "_fields": {"kind": null, "value": " {0}"}}}}, "keywords": []}}, "target": {"_type": "Name", "_fields": {"id": "route_cmd", "ctx": {"_type": "Store", "_fields": {}}}}}}], "test": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "pref"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "params", "value": {"_type": "Name", "_fields": {"id": "module", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "orelse": []}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "route_cmd", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "append", "value": {"_type": "Name", "_fields": {"id": "commands", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "name": "set_route", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def set_route(module, commands, prefix): route_cmd = 'ip route {0} {1}'.format(prefix, module.params['next_hop']) if module.params['route_name']: route_cmd += ' name {0}'.format(module.params['route_name']) if module.params['tag']: route_cmd += ' tag {0}'.format(module.params['tag']) if module.params['pref']: route_cmd += ' {0}'.format(module.params['pref']) commands.append(route_cmd)
14,416
[ 0.03248724341392517, -0.011553781107068062, 0.005807948764413595, 0.024432726204395294, 0.005321364849805832, 0.017682667821645737, 0.013230942189693451, 0.035572394728660583, 0.02627553418278694, 0.06555424630641937, -0.019887825474143028, -0.03511686623096466, 0.00940556451678276, -0.031...
10
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "module", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "prefix", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "/"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "split", "value": {"_type": "Name", "_fields": {"id": "prefix", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "splitted_prefix", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "splitted_prefix", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "address", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "If", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "fail_json", "value": {"_type": "Name", "_fields": {"id": "module", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "msg", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "Incorrect address format."}}}}, {"_type": "keyword", "_fields": {"arg": "address", "value": {"_type": "Name", "_fields": {"id": "address", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Gt", "_fields": {}}], "left": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "splitted_prefix", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "len", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": 2}}]}}, "orelse": [{"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}, "value": {"_type": "Name", "_fields": {"id": "splitted_prefix", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "mask", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "address", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "mask", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "module", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "network_from_string", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "network", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "network", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "str", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": "/"}}}}, "right": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "mask", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "str", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "normalized_prefix", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "splitted_prefix", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "len", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": 2}}]}}, "orelse": [{"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "prefix", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": "/"}}}}, "right": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 32}}], "func": {"_type": "Name", "_fields": {"id": "str", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "normalized_prefix", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}]}}]}}, {"_type": "Return", "_fields": {"value": {"_type": "Name", "_fields": {"id": "normalized_prefix", "ctx": {"_type": "Load", "_fields": {}}}}}}], "name": "normalize_prefix", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def normalize_prefix(module, prefix): splitted_prefix = prefix.split('/') address = splitted_prefix[0] if len(splitted_prefix) > 2: module.fail_json(msg='Incorrect address format.', address=address) elif len(splitted_prefix) == 2: mask = splitted_prefix[1] network = network_from_string(address, mask, module) normalized_prefix = str(network) + '/' + str(mask) else: normalized_prefix = prefix + '/' + str(32) return normalized_prefix
14,417
[ -0.0006018015556037426, 0.002843463560566306, -0.0033311371225863695, -0.037941932678222656, -0.023707475513219833, 0.017238400876522064, -0.006487771403044462, 0.012495659291744232, 0.013661090284585953, 0.09792109578847885, -0.0008880954701453447, -0.051553163677453995, 0.02333354018628597...
11
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "dict", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "prefix", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "dict", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "required", "value": {"_type": "Constant", "_fields": {"kind": null, "value": true}}}}, {"_type": "keyword", "_fields": {"arg": "type", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "str"}}}}]}}}}, {"_type": "keyword", "_fields": {"arg": "next_hop", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "dict", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "required", "value": {"_type": "Constant", "_fields": {"kind": null, "value": true}}}}, {"_type": "keyword", "_fields": {"arg": "type", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "str"}}}}]}}}}, {"_type": "keyword", "_fields": {"arg": "vrf", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "dict", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "type", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "str"}}}}, {"_type": "keyword", "_fields": {"arg": "default", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "default"}}}}]}}}}, {"_type": "keyword", "_fields": {"arg": "tag", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "dict", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "type", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "str"}}}}]}}}}, {"_type": "keyword", "_fields": {"arg": "route_name", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "dict", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "type", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "str"}}}}]}}}}, {"_type": "keyword", "_fields": {"arg": "pref", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "dict", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "type", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "str"}}}}]}}}}, {"_type": "keyword", "_fields": {"arg": "state", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "dict", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "choices", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": "absent"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "present"}}]}}}}, {"_type": "keyword", "_fields": {"arg": "default", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "present"}}}}]}}}}, {"_type": "keyword", "_fields": {"arg": "include_defaults", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "dict", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "default", "value": {"_type": "Constant", "_fields": {"kind": null, "value": true}}}}]}}}}, {"_type": "keyword", "_fields": {"arg": "config", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "dict", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "keyword", "_fields": {"arg": "save", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "dict", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "type", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "bool"}}}}, {"_type": "keyword", "_fields": {"arg": "default", "value": {"_type": "Constant", "_fields": {"kind": null, "value": false}}}}]}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "argument_spec", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "nxos_argument_spec", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "update", "value": {"_type": "Name", "_fields": {"id": "argument_spec", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "AnsibleModule", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "argument_spec", "value": {"_type": "Name", "_fields": {"id": "argument_spec", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "supports_check_mode", "value": {"_type": "Constant", "_fields": {"kind": null, "value": true}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "module", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "list", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "warnings", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "module", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "warnings", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "check_args", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "state"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "params", "value": {"_type": "Name", "_fields": {"id": "module", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "state", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "dict", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "changed", "value": {"_type": "Constant", "_fields": {"kind": null, "value": false}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "result", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "list", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "warnings", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "normalize_prefix"}}, {"_type": "Name", "_fields": {"id": "module", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "prefix"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "params", "value": {"_type": "Name", "_fields": {"id": "module", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "func": {"_type": "Name", "_fields": {"id": "invoke", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "prefix", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "get_existing"}}, {"_type": "Name", "_fields": {"id": "module", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "prefix", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "warnings", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "invoke", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "existing", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Name", "_fields": {"id": "existing", "ctx": {"_type": "Load", "_fields": {}}}}, "targets": [{"_type": "Name", "_fields": {"id": "end_state", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": "route_name"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "vrf"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "pref"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "tag"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "next_hop"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "prefix"}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "args", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "GeneratorExp", "_fields": {"elt": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "k", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "v", "ctx": {"_type": "Load", "_fields": {}}}}]}}, "generators": [{"_type": "comprehension", "_fields": {"ifs": [{"_type": "BoolOp", "_fields": {"op": {"_type": "And", "_fields": {}}, "values": [{"_type": "Compare", "_fields": {"ops": [{"_type": "IsNot", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "v", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": null}}]}}, {"_type": "Compare", "_fields": {"ops": [{"_type": "In", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "k", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "Name", "_fields": {"id": "args", "ctx": {"_type": "Load", "_fields": {}}}}]}}]}}], "iter": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "items", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "params", "value": {"_type": "Name", "_fields": {"id": "module", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}, "target": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "k", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "v", "ctx": {"_type": "Store", "_fields": {}}}}]}}, "is_async": 0}}]}}], "func": {"_type": "Name", "_fields": {"id": "dict", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "proposed", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "CustomNetworkConfig", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "indent", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 3}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "candidate", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Mod", "_fields": {}}, "left": {"_type": "Constant", "_fields": {"kind": null, "value": "state_%s"}}, "right": {"_type": "Name", "_fields": {"id": "state", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Name", "_fields": {"id": "module", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "candidate", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "prefix", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "invoke", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "module", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "candidate", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "load_config", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}], "test": {"_type": "BoolOp", "_fields": {"op": {"_type": "Or", "_fields": {}}, "values": [{"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "state", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": "present"}}]}}, {"_type": "BoolOp", "_fields": {"op": {"_type": "And", "_fields": {}}, "values": [{"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "state", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": "absent"}}]}}, {"_type": "Name", "_fields": {"id": "existing", "ctx": {"_type": "Load", "_fields": {}}}}]}}]}}, "orelse": [{"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": []}}, "targets": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "updates"}}, "value": {"_type": "Name", "_fields": {"id": "result", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}]}}, {"_type": "Assign", "_fields": {"value": {"_type": "Name", "_fields": {"id": "warnings", "ctx": {"_type": "Load", "_fields": {}}}}, "targets": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "warnings"}}, "value": {"_type": "Name", "_fields": {"id": "result", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "get_existing"}}, {"_type": "Name", "_fields": {"id": "module", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "prefix", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "warnings", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "invoke", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "end_state", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Name", "_fields": {"id": "end_state", "ctx": {"_type": "Load", "_fields": {}}}}, "targets": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "end_state"}}, "value": {"_type": "Name", "_fields": {"id": "result", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Name", "_fields": {"id": "existing", "ctx": {"_type": "Load", "_fields": {}}}}, "targets": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "existing"}}, "value": {"_type": "Name", "_fields": {"id": "result", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Name", "_fields": {"id": "proposed", "ctx": {"_type": "Load", "_fields": {}}}}, "targets": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "proposed"}}, "value": {"_type": "Name", "_fields": {"id": "result", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Gt", "_fields": {}}], "left": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_verbosity", "value": {"_type": "Name", "_fields": {"id": "module", "ctx": {"_type": "Load", "_fields": {}}}}}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": 0}}]}}, "orelse": []}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "exit_json", "value": {"_type": "Name", "_fields": {"id": "module", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": null, "value": {"_type": "Name", "_fields": {"id": "result", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}}}], "name": "main", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def main(): argument_spec = dict( prefix=dict(required=True, type='str'), next_hop=dict(required=True, type='str'), vrf=dict(type='str', default='default'), tag=dict(type='str'), route_name=dict(type='str'), pref=dict(type='str'), state=dict(choices=['absent', 'present'], default='present'), include_defaults=dict(default=True), config=dict(), save=dict(type='bool', default=False) ) argument_spec.update(nxos_argument_spec) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() check_args(module, warnings) state = module.params['state'] result = dict(changed=False) warnings = list() prefix = invoke('normalize_prefix', module, module.params['prefix']) existing = invoke('get_existing', module, prefix, warnings) end_state = existing args = ['route_name', 'vrf', 'pref', 'tag', 'next_hop', 'prefix'] proposed = dict((k, v) for k, v in module.params.items() if v is not None and k in args) if state == 'present' or (state == 'absent' and existing): candidate = CustomNetworkConfig(indent=3) invoke('state_%s' % state, module, candidate, prefix) load_config(module, candidate) else: result['updates'] = [] result['warnings'] = warnings if module._verbosity > 0: end_state = invoke('get_existing', module, prefix, warnings) result['end_state'] = end_state result['existing'] = existing result['proposed'] = proposed module.exit_json(**result)
14,418
[ 0.004288012161850929, 0.027015693485736847, 0.024367570877075195, -0.04533388838171959, -0.005317499861121178, 0.009165170602500439, -0.028181837871670723, -0.018318194895982742, -0.004959153011441231, 0.027137165889143944, 0.0035956138744950294, -0.004257644060999155, -0.008375593461096287,...
11
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "argv", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Try", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "argv", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "FLAGS", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "argv", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}], "orelse": [], "handlers": [{"_type": "ExceptHandler", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "%s\\nUsage: %s ARGS\\n%s"}}, {"_type": "Name", "_fields": {"id": "e", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "argv", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Name", "_fields": {"id": "FLAGS", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "error", "value": {"_type": "Name", "_fields": {"id": "logging", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "exit", "value": {"_type": "Name", "_fields": {"id": "sys", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "name": "e", "type": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "FlagsError", "value": {"_type": "Name", "_fields": {"id": "gflags", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "finalbody": []}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "logging", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "upper", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "logging_level", "value": {"_type": "Name", "_fields": {"id": "FLAGS", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}], "func": {"_type": "Name", "_fields": {"id": "getattr", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "numeric_level", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "If", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Mod", "_fields": {}}, "left": {"_type": "Constant", "_fields": {"kind": null, "value": "Invalid log level: %s"}}, "right": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "logging_level", "value": {"_type": "Name", "_fields": {"id": "FLAGS", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "error", "value": {"_type": "Name", "_fields": {"id": "logging", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "exit", "value": {"_type": "Name", "_fields": {"id": "sys", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "test": {"_type": "UnaryOp", "_fields": {"op": {"_type": "Not", "_fields": {}}, "operand": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "numeric_level", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "int", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "isinstance", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, "orelse": []}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "basicConfig", "value": {"_type": "Name", "_fields": {"id": "logging", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "level", "value": {"_type": "Name", "_fields": {"id": "numeric_level", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}}}, {"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "debuglevel", "value": {"_type": "Name", "_fields": {"id": "httplib2", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "logging_level", "value": {"_type": "Name", "_fields": {"id": "FLAGS", "ctx": {"_type": "Load", "_fields": {}}}}}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": "DEBUG"}}]}}, "orelse": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "message", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "message", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "fatal", "value": {"_type": "Name", "_fields": {"id": "logging", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 2}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "exit", "value": {"_type": "Name", "_fields": {"id": "sys", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "name": "die", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "If", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "You must specify a client secrets file via --client_secrets"}}], "func": {"_type": "Name", "_fields": {"id": "die", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Is", "_fields": {}}], "left": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "client_secrets", "value": {"_type": "Name", "_fields": {"id": "FLAGS", "ctx": {"_type": "Load", "_fields": {}}}}}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": null}}]}}, "orelse": []}}, {"_type": "If", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "You must specify a project ID via --project_id"}}], "func": {"_type": "Name", "_fields": {"id": "die", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Is", "_fields": {}}], "left": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "project_id", "value": {"_type": "Name", "_fields": {"id": "FLAGS", "ctx": {"_type": "Load", "_fields": {}}}}}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": null}}]}}, "orelse": []}}, {"_type": "If", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "You must specify a bucket via --bucket"}}], "func": {"_type": "Name", "_fields": {"id": "die", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}], "test": {"_type": "UnaryOp", "_fields": {"op": {"_type": "Not", "_fields": {}}, "operand": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "bucket", "value": {"_type": "Name", "_fields": {"id": "FLAGS", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "orelse": []}}, {"_type": "If", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "You must specify a published version identifier via --publish_version"}}], "func": {"_type": "Name", "_fields": {"id": "die", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Is", "_fields": {}}], "left": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "publish_version", "value": {"_type": "Name", "_fields": {"id": "FLAGS", "ctx": {"_type": "Load", "_fields": {}}}}}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": null}}]}}, "orelse": []}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "client_secrets", "value": {"_type": "Name", "_fields": {"id": "FLAGS", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Name", "_fields": {"id": "_authenticate", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "auth_http", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": []}}, "targets": [{"_type": "Name", "_fields": {"id": "published", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "For", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Mod", "_fields": {}}, "left": {"_type": "Constant", "_fields": {"kind": null, "value": "%s/%s"}}, "right": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "publish_version", "value": {"_type": "Name", "_fields": {"id": "FLAGS", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "f", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "basename", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "path", "value": {"_type": "Name", "_fields": {"id": "os", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}]}}}}, "targets": [{"_type": "Name", "_fields": {"id": "object_name", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "Publishing %s as %s"}}, {"_type": "Name", "_fields": {"id": "f", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "object_name", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "info", "value": {"_type": "Name", "_fields": {"id": "logging", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "auth_http", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "project_id", "value": {"_type": "Name", "_fields": {"id": "FLAGS", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "bucket", "value": {"_type": "Name", "_fields": {"id": "FLAGS", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Name", "_fields": {"id": "f", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "object_name", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "acl", "value": {"_type": "Name", "_fields": {"id": "FLAGS", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Name", "_fields": {"id": "_upload", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "object_name", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "append", "value": {"_type": "Name", "_fields": {"id": "published", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "iter": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "publish", "value": {"_type": "Name", "_fields": {"id": "FLAGS", "ctx": {"_type": "Load", "_fields": {}}}}}}, "orelse": [], "target": {"_type": "Name", "_fields": {"id": "f", "ctx": {"_type": "Store", "_fields": {}}}}, "type_comment": null}}, {"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Mod", "_fields": {}}, "left": {"_type": "Constant", "_fields": {"kind": null, "value": "http://%s.storage.googleapis.com/"}}, "right": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "bucket", "value": {"_type": "Name", "_fields": {"id": "FLAGS", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "base_url", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Mod", "_fields": {}}, "left": {"_type": "Constant", "_fields": {"kind": null, "value": "Published:\n %s"}}, "right": {"_type": "Call", "_fields": {"args": [{"_type": "ListComp", "_fields": {"elt": {"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "base_url", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "Name", "_fields": {"id": "p", "ctx": {"_type": "Load", "_fields": {}}}}}}, "generators": [{"_type": "comprehension", "_fields": {"ifs": [], "iter": {"_type": "Name", "_fields": {"id": "published", "ctx": {"_type": "Load", "_fields": {}}}}, "target": {"_type": "Name", "_fields": {"id": "p", "ctx": {"_type": "Store", "_fields": {}}}}, "is_async": 0}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "join", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "\n "}}}}, "keywords": []}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "info", "value": {"_type": "Name", "_fields": {"id": "logging", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "test": {"_type": "Name", "_fields": {"id": "published", "ctx": {"_type": "Load", "_fields": {}}}}, "orelse": []}}], "name": "main", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def main(argv): try: argv = FLAGS(argv) except gflags.FlagsError as e: logging.error('%s\\nUsage: %s ARGS\\n%s', e, argv[0], FLAGS) sys.exit(1) numeric_level = getattr(logging, FLAGS.logging_level.upper()) if not isinstance(numeric_level, int): logging.error('Invalid log level: %s' % FLAGS.logging_level) sys.exit(1) logging.basicConfig(level=numeric_level) if FLAGS.logging_level == 'DEBUG': httplib2.debuglevel = 1 def die(message): logging.fatal(message) sys.exit(2) if FLAGS.client_secrets is None: die('You must specify a client secrets file via --client_secrets') if FLAGS.project_id is None: die('You must specify a project ID via --project_id') if not FLAGS.bucket: die('You must specify a bucket via --bucket') if FLAGS.publish_version is None: die('You must specify a published version identifier via ' '--publish_version') auth_http = _authenticate(FLAGS.client_secrets) published = [] for f in FLAGS.publish: object_name = '%s/%s' % (FLAGS.publish_version, os.path.basename(f)) logging.info('Publishing %s as %s', f, object_name) _upload(auth_http, FLAGS.project_id, FLAGS.bucket, f, object_name, FLAGS.acl) published.append(object_name) if published: base_url = 'http://%s.storage.googleapis.com/' % FLAGS.bucket logging.info('Published:\n %s' % '\n '.join([base_url + p for p in published]))
14,419
[ -0.014798929914832115, -0.009809311479330063, -0.028794577345252037, 0.020236531272530556, 0.027414578944444656, -0.014417885802686214, -0.034396953880786896, -0.0015718069626018405, 0.008933939971029758, 0.0759204626083374, -0.01899041421711445, -0.07620882242918015, 0.04803215712308884, ...
13
{"_type": "Module", "_fields": {"body": [{"_type": "ClassDef", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "request", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": []}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "_prefixes", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": []}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "primary_subdomains", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": ""}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "primary_domain", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "idna"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "decode", "value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": ":"}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "split", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "host", "value": {"_type": "Name", "_fields": {"id": "request", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}}}, "keywords": []}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "_domain", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_domain", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "subdomain", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Name", "_fields": {"id": "request", "ctx": {"_type": "Load", "_fields": {}}}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "request", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}], "name": "__init__", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "type", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "__new__", "value": {"_type": "Name", "_fields": {"id": "object", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "copy", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "__dict__", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "update", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "__dict__", "value": {"_type": "Name", "_fields": {"id": "copy", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}, {"_type": "Return", "_fields": {"value": {"_type": "Name", "_fields": {"id": "copy", "ctx": {"_type": "Load", "_fields": {}}}}}}], "name": "__copy__", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "prefix", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "__copy__", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "AugAssign", "_fields": {"op": {"_type": "Add", "_fields": {}}, "value": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "prefix", "ctx": {"_type": "Load", "_fields": {}}}}]}}, "target": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "_prefixes", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Return", "_fields": {"value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "name": "add_prefix", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "subdomain", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "alias_matched", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "__copy__", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "subdomain", "ctx": {"_type": "Load", "_fields": {}}}}]}}, "right": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "primary_subdomains", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "primary_subdomains", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "primary_subdomains", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "join", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "."}}}}, "keywords": []}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "primary_domain", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}], "test": {"_type": "Name", "_fields": {"id": "subdomain", "ctx": {"_type": "Load", "_fields": {}}}}, "orelse": []}}, {"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "."}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "rstrip", "value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "alias_matched", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "len", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "subdomain", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": []}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "subdomain", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}], "test": {"_type": "Name", "_fields": {"id": "alias_matched", "ctx": {"_type": "Load", "_fields": {}}}}, "orelse": []}}, {"_type": "Return", "_fields": {"value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "name": "add_subdomain", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "path", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "request", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "path", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "len", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_prefixes", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Name", "_fields": {"id": "map", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}], "func": {"_type": "Name", "_fields": {"id": "sum", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "length", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Slice", "_fields": {"step": null, "lower": {"_type": "Name", "_fields": {"id": "length", "ctx": {"_type": "Load", "_fields": {}}}}, "upper": null}}, "value": {"_type": "Name", "_fields": {"id": "path", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "path", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}], "test": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_prefixes", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "orelse": []}}, {"_type": "Return", "_fields": {"value": {"_type": "Name", "_fields": {"id": "path", "ctx": {"_type": "Load", "_fields": {}}}}}}], "name": "path", "returns": null, "type_params": [], "type_comment": null, "decorator_list": [{"_type": "Name", "_fields": {"id": "property", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "name": "RouteState", "bases": [{"_type": "Name", "_fields": {"id": "object", "ctx": {"_type": "Load", "_fields": {}}}}], "keywords": [], "type_params": [], "decorator_list": []}}], "type_ignores": []}}
class RouteState(object): def __init__(self, request): self._prefixes = () # matched subdomain with aliases replaced by their main value self.primary_subdomains = () # tuple to be sure it's readonly self.primary_domain = '' # remaining subdomain part for match self._domain = request.host.split(':', 1)[0].decode('idna') self.subdomain = self._domain self.request = request def __copy__(self): copy = object.__new__(type(self)) copy.__dict__.update(self.__dict__) return copy def add_prefix(self, prefix): self = self.__copy__() self._prefixes += (prefix,) return self def add_subdomain(self, subdomain, alias_matched): self = self.__copy__() if subdomain: self.primary_subdomains = (subdomain, ) + self.primary_subdomains self.primary_domain = '.'.join(self.primary_subdomains) if alias_matched: self.subdomain = self.subdomain[:-len(alias_matched)].rstrip('.') return self @property def path(self): path = self.request.path if self._prefixes: length = sum(map(len, self._prefixes)) path = path[length:] return path
14,420
[ 0.006236783694475889, -0.057028163224458694, 0.00965331681072712, -0.030039703473448753, 0.03367111086845398, -0.01084050815552473, 0.017104150727391243, 0.032360367476940155, 0.015986794605851173, -0.003478309605270624, 0.03263970464468002, -0.006999594625085592, 0.002753102220594883, 0.0...
9
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "Consumer", "value": {"_type": "Name", "_fields": {"id": "oauth", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "key", "value": {"_type": "Name", "_fields": {"id": "CONSUMER_KEY", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "secret", "value": {"_type": "Name", "_fields": {"id": "CONSUMER_SECRET", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "consumer", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "Token", "value": {"_type": "Name", "_fields": {"id": "oauth", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "key", "value": {"_type": "Name", "_fields": {"id": "ACCESS_TOKEN_KEY", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "secret", "value": {"_type": "Name", "_fields": {"id": "ACCESS_TOKEN_SECRET", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "token", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "consumer", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "token", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "from_consumer_and_token", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "Request", "value": {"_type": "Name", "_fields": {"id": "oauth", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "http_url", "value": {"_type": "Name", "_fields": {"id": "TWITTER_URL", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "request", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "SignatureMethod_HMAC_SHA1", "value": {"_type": "Name", "_fields": {"id": "oauth", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Name", "_fields": {"id": "consumer", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "token", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sign_request", "value": {"_type": "Name", "_fields": {"id": "request", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "to_url", "value": {"_type": "Name", "_fields": {"id": "request", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "urlopen", "value": {"_type": "Name", "_fields": {"id": "urllib2", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "res", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "For", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "r", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "loads", "value": {"_type": "Name", "_fields": {"id": "json", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "data", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "If", "_fields": {"body": [{"_type": "Continue", "_fields": {}}], "test": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "delete"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "has_key", "value": {"_type": "Name", "_fields": {"id": "data", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "orelse": []}}, {"_type": "If", "_fields": {"body": [{"_type": "Continue", "_fields": {}}], "test": {"_type": "UnaryOp", "_fields": {"op": {"_type": "Not", "_fields": {}}, "operand": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "lang"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "has_key", "value": {"_type": "Name", "_fields": {"id": "data", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "orelse": []}}, {"_type": "Assign", "_fields": {"value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "lang"}}, "value": {"_type": "Name", "_fields": {"id": "data", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "lang", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "If", "_fields": {"body": [{"_type": "Pass", "_fields": {}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "lang", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": "ja"}}]}}, "orelse": [{"_type": "If", "_fields": {"body": [{"_type": "Pass", "_fields": {}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "lang", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": "en"}}]}}, "orelse": [{"_type": "Continue", "_fields": {}}]}}]}}, {"_type": "Assign", "_fields": {"value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "id_str"}}, "value": {"_type": "Name", "_fields": {"id": "data", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "id_str", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "lang"}}, "value": {"_type": "Name", "_fields": {"id": "data", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "lang", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "text"}}, "value": {"_type": "Name", "_fields": {"id": "data", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "text", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "created_at"}}, "value": {"_type": "Name", "_fields": {"id": "data", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "created_at", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "timestamp_ms"}}, "value": {"_type": "Name", "_fields": {"id": "data", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Name", "_fields": {"id": "int", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "timestamp_ms", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "id_str", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "print", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "\n INSERT INTO tweets (id_str, lang, text, created_at, timestamp_ms)\n VALUES (%s, %s, %s, %s, %s)\n "}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "id_str", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "lang", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "text", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "created_at", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "timestamp_ms", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "execute", "value": {"_type": "Name", "_fields": {"id": "session", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "iter": {"_type": "Name", "_fields": {"id": "res", "ctx": {"_type": "Load", "_fields": {}}}}, "orelse": [], "target": {"_type": "Name", "_fields": {"id": "r", "ctx": {"_type": "Store", "_fields": {}}}}, "type_comment": null}}, {"_type": "Pass", "_fields": {}}], "name": "streaming", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def streaming(): consumer = oauth.Consumer(key=CONSUMER_KEY, secret=CONSUMER_SECRET) token = oauth.Token(key=ACCESS_TOKEN_KEY, secret=ACCESS_TOKEN_SECRET) request = oauth.Request.from_consumer_and_token(consumer, token, http_url=TWITTER_URL) request.sign_request(oauth.SignatureMethod_HMAC_SHA1(), consumer, token) res = urllib2.urlopen(request.to_url()) for r in res: data = json.loads(r) if data.has_key('delete'): continue if not data.has_key('lang'): continue lang = data['lang'] if lang == 'ja': pass elif lang == 'en': pass else: continue id_str = data['id_str'] lang = data['lang'] text = data['text'] created_at = data['created_at'] timestamp_ms = int(data['timestamp_ms']) print(id_str) # print(timestamp_ms) session.execute( """ INSERT INTO tweets (id_str, lang, text, created_at, timestamp_ms) VALUES (%s, %s, %s, %s, %s) """, (id_str, lang, text, created_at, timestamp_ms) ) pass
14,421
[ -0.00025681228726170957, 0.0015112932305783033, 0.02639653906226158, -0.011272849515080452, 0.026202920824289322, 0.010783427394926548, -0.0007475792081095278, -0.024180691689252853, 0.012423798441886902, 0.04844743758440018, 0.005996768828481436, -0.054126888513565063, 0.026719234883785248,...
12
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "subdomain", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "alias_matched", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "__copy__", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "subdomain", "ctx": {"_type": "Load", "_fields": {}}}}]}}, "right": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "primary_subdomains", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "primary_subdomains", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "primary_subdomains", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "join", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "."}}}}, "keywords": []}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "primary_domain", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}], "test": {"_type": "Name", "_fields": {"id": "subdomain", "ctx": {"_type": "Load", "_fields": {}}}}, "orelse": []}}, {"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "."}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "rstrip", "value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "alias_matched", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "len", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "subdomain", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": []}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "subdomain", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}], "test": {"_type": "Name", "_fields": {"id": "alias_matched", "ctx": {"_type": "Load", "_fields": {}}}}, "orelse": []}}, {"_type": "Return", "_fields": {"value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "name": "add_subdomain", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def add_subdomain(self, subdomain, alias_matched): self = self.__copy__() if subdomain: self.primary_subdomains = (subdomain, ) + self.primary_subdomains self.primary_domain = '.'.join(self.primary_subdomains) if alias_matched: self.subdomain = self.subdomain[:-len(alias_matched)].rstrip('.') return self
14,422
[ -0.003719030413776636, -0.04100140556693077, 0.02823450043797493, -0.04428241029381752, 0.021315373480319977, 0.013023581355810165, 0.038211435079574585, 0.00048440860700793564, -0.04794285073876381, -0.007800756953656673, 0.01094784401357174, -0.03970685601234436, -0.025846285745501518, -...
14
{"_type": "Module", "_fields": {"body": [{"_type": "ClassDef", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "which_set", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "n_datapoints", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "fname", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "preproc", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [{"_type": "Constant", "_fields": {"kind": null, "value": "train"}}, {"_type": "Constant", "_fields": {"kind": null, "value": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": "mnist.pkl.gz"}}, {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": []}}], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "preproc", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "__init__", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "MNIST", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "super", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "Loading MNIST data"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "info", "value": {"_type": "Name", "_fields": {"id": "_logger", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "fname", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "datapath", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "fname", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "open", "value": {"_type": "Name", "_fields": {"id": "gzip", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "open_func", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Slice", "_fields": {"step": null, "lower": {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 3}}}}, "upper": null}}, "value": {"_type": "Name", "_fields": {"id": "fname", "ctx": {"_type": "Load", "_fields": {}}}}}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": ".gz"}}]}}, "orelse": [{"_type": "Assign", "_fields": {"value": {"_type": "Name", "_fields": {"id": "open", "ctx": {"_type": "Load", "_fields": {}}}}, "targets": [{"_type": "Name", "_fields": {"id": "open_func", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}]}}, {"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "f", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "load", "value": {"_type": "Name", "_fields": {"id": "pickle", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "train_x", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "train_y", "ctx": {"_type": "Store", "_fields": {}}}}]}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "valid_x", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "valid_y", "ctx": {"_type": "Store", "_fields": {}}}}]}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "test_x", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "test_y", "ctx": {"_type": "Store", "_fields": {}}}}]}}]}}], "type_comment": null}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "fname", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "open_func", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "optional_vars": {"_type": "Name", "_fields": {"id": "f", "ctx": {"_type": "Store", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "train_x", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "train_y", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "n_datapoints", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "prepare", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "X", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "Y", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}], "type_comment": null}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "which_set", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": "train"}}]}}, "orelse": [{"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "valid_x", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "valid_y", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "n_datapoints", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "prepare", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "X", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "Y", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}], "type_comment": null}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "which_set", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": "valid"}}]}}, "orelse": [{"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "test_x", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "test_y", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "n_datapoints", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "prepare", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "X", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "Y", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}], "type_comment": null}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "which_set", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": "test"}}]}}, "orelse": [{"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "train_x", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "valid_x", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "concatenate", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "train_x", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "train_y", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "valid_y", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "concatenate", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "train_y", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "train_x", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "train_y", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "n_datapoints", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "prepare", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "X", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "Y", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}], "type_comment": null}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "which_set", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": "salakhutdinov_train"}}]}}, "orelse": [{"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Slice", "_fields": {"step": {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}}}, "lower": null, "upper": null}}, "value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "train_x", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "valid_x", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "concatenate", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "train_x", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Slice", "_fields": {"step": {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}}}, "lower": null, "upper": null}}, "value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "train_y", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "valid_y", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "concatenate", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "train_y", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "train_x", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "train_y", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "n_datapoints", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "prepare", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "X", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "Y", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}], "type_comment": null}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "which_set", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": "salakhutdinov_valid"}}]}}, "orelse": [{"_type": "Raise", "_fields": {"exc": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Mod", "_fields": {}}, "left": {"_type": "Constant", "_fields": {"kind": null, "value": "Unknown dataset %s"}}, "right": {"_type": "Name", "_fields": {"id": "which_set", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Name", "_fields": {"id": "ValueError", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "cause": null}}]}}]}}]}}]}}]}}, {"_type": "Assign", "_fields": {"value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "shape", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "X", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "n_datapoints", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}], "name": "__init__", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "x", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "y", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "n_datapoints", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "shape", "value": {"_type": "Name", "_fields": {"id": "x", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "N", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assert", "_fields": {"msg": null, "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "N", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "shape", "value": {"_type": "Name", "_fields": {"id": "y", "ctx": {"_type": "Load", "_fields": {}}}}}}}}]}}}}, {"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Name", "_fields": {"id": "n_datapoints", "ctx": {"_type": "Load", "_fields": {}}}}, "targets": [{"_type": "Name", "_fields": {"id": "N", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "IsNot", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "n_datapoints", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": null}}]}}, "orelse": []}}, {"_type": "Assign", "_fields": {"value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": {"_type": "Name", "_fields": {"id": "N", "ctx": {"_type": "Load", "_fields": {}}}}}}, "value": {"_type": "Name", "_fields": {"id": "x", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "x", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": {"_type": "Name", "_fields": {"id": "N", "ctx": {"_type": "Load", "_fields": {}}}}}}, "value": {"_type": "Name", "_fields": {"id": "y", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "y", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "N", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 10}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "zeros", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "dtype", "value": {"_type": "Name", "_fields": {"id": "floatX", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "one_hot", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "For", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}, "targets": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "slice": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "n", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Name", "_fields": {"id": "n", "ctx": {"_type": "Load", "_fields": {}}}}, "value": {"_type": "Name", "_fields": {"id": "y", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "value": {"_type": "Name", "_fields": {"id": "one_hot", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}], "iter": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "N", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "xrange", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "orelse": [], "target": {"_type": "Name", "_fields": {"id": "n", "ctx": {"_type": "Store", "_fields": {}}}}, "type_comment": null}}, {"_type": "Return", "_fields": {"value": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "floatX", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "astype", "value": {"_type": "Name", "_fields": {"id": "x", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "floatX", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "astype", "value": {"_type": "Name", "_fields": {"id": "one_hot", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}]}}}}], "name": "prepare", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "name": "MNIST", "bases": [{"_type": "Name", "_fields": {"id": "DataSet", "ctx": {"_type": "Load", "_fields": {}}}}], "keywords": [], "type_params": [], "decorator_list": []}}], "type_ignores": []}}
class MNIST(DataSet): def __init__(self, which_set='train', n_datapoints=None, fname="mnist.pkl.gz", preproc=[]): super(MNIST, self).__init__(preproc) _logger.info("Loading MNIST data") fname = datapath(fname) if fname[-3:] == ".gz": open_func = gzip.open else: open_func = open with open_func(fname) as f: (train_x, train_y), (valid_x, valid_y), (test_x, test_y) = pickle.load(f) if which_set == 'train': self.X, self.Y = self.prepare(train_x, train_y, n_datapoints) elif which_set == 'valid': self.X, self.Y = self.prepare(valid_x, valid_y, n_datapoints) elif which_set == 'test': self.X, self.Y = self.prepare(test_x, test_y, n_datapoints) elif which_set == 'salakhutdinov_train': train_x = np.concatenate([train_x, valid_x]) train_y = np.concatenate([train_y, valid_y]) self.X, self.Y = self.prepare(train_x, train_y, n_datapoints) elif which_set == 'salakhutdinov_valid': train_x = np.concatenate([train_x, valid_x])[::-1] train_y = np.concatenate([train_y, valid_y])[::-1] self.X, self.Y = self.prepare(train_x, train_y, n_datapoints) else: raise ValueError("Unknown dataset %s" % which_set) self.n_datapoints = self.X.shape[0] def prepare(self, x, y, n_datapoints): N = x.shape[0] assert N == y.shape[0] if n_datapoints is not None: N = n_datapoints x = x[:N] y = y[:N] one_hot = np.zeros((N, 10), dtype=floatX) for n in xrange(N): one_hot[n, y[n]] = 1. return x.astype(floatX), one_hot.astype(floatX)
14,423
[ 0.005900433752685785, -0.03255411982536316, 0.03695332258939743, -0.04018674045801163, 0.008704926818609238, 0.015958117321133614, 0.044497959315776825, 0.019796423614025116, -0.049271099269390106, 0.010239150375127792, 0.0182786975055933, -0.008418979123234749, -0.018091730773448944, -0.0...
13
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "which_set", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "n_datapoints", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "fname", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "preproc", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [{"_type": "Constant", "_fields": {"kind": null, "value": "train"}}, {"_type": "Constant", "_fields": {"kind": null, "value": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": "mnist.pkl.gz"}}, {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": []}}], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "preproc", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "__init__", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "MNIST", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "super", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "Loading MNIST data"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "info", "value": {"_type": "Name", "_fields": {"id": "_logger", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "fname", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "datapath", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "fname", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "open", "value": {"_type": "Name", "_fields": {"id": "gzip", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "open_func", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Slice", "_fields": {"step": null, "lower": {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 3}}}}, "upper": null}}, "value": {"_type": "Name", "_fields": {"id": "fname", "ctx": {"_type": "Load", "_fields": {}}}}}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": ".gz"}}]}}, "orelse": [{"_type": "Assign", "_fields": {"value": {"_type": "Name", "_fields": {"id": "open", "ctx": {"_type": "Load", "_fields": {}}}}, "targets": [{"_type": "Name", "_fields": {"id": "open_func", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}]}}, {"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "f", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "load", "value": {"_type": "Name", "_fields": {"id": "pickle", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "train_x", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "train_y", "ctx": {"_type": "Store", "_fields": {}}}}]}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "valid_x", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "valid_y", "ctx": {"_type": "Store", "_fields": {}}}}]}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "test_x", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "test_y", "ctx": {"_type": "Store", "_fields": {}}}}]}}]}}], "type_comment": null}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "fname", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "open_func", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "optional_vars": {"_type": "Name", "_fields": {"id": "f", "ctx": {"_type": "Store", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "train_x", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "train_y", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "n_datapoints", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "prepare", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "X", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "Y", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}], "type_comment": null}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "which_set", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": "train"}}]}}, "orelse": [{"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "valid_x", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "valid_y", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "n_datapoints", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "prepare", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "X", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "Y", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}], "type_comment": null}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "which_set", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": "valid"}}]}}, "orelse": [{"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "test_x", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "test_y", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "n_datapoints", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "prepare", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "X", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "Y", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}], "type_comment": null}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "which_set", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": "test"}}]}}, "orelse": [{"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "train_x", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "valid_x", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "concatenate", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "train_x", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "train_y", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "valid_y", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "concatenate", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "train_y", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "train_x", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "train_y", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "n_datapoints", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "prepare", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "X", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "Y", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}], "type_comment": null}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "which_set", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": "salakhutdinov_train"}}]}}, "orelse": [{"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Slice", "_fields": {"step": {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}}}, "lower": null, "upper": null}}, "value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "train_x", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "valid_x", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "concatenate", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "train_x", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Slice", "_fields": {"step": {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}}}, "lower": null, "upper": null}}, "value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "train_y", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "valid_y", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "concatenate", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "train_y", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "train_x", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "train_y", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "n_datapoints", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "prepare", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "X", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "Y", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}], "type_comment": null}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "which_set", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": "salakhutdinov_valid"}}]}}, "orelse": [{"_type": "Raise", "_fields": {"exc": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Mod", "_fields": {}}, "left": {"_type": "Constant", "_fields": {"kind": null, "value": "Unknown dataset %s"}}, "right": {"_type": "Name", "_fields": {"id": "which_set", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Name", "_fields": {"id": "ValueError", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "cause": null}}]}}]}}]}}]}}]}}, {"_type": "Assign", "_fields": {"value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "shape", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "X", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "n_datapoints", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}], "name": "__init__", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def __init__(self, which_set='train', n_datapoints=None, fname="mnist.pkl.gz", preproc=[]): super(MNIST, self).__init__(preproc) _logger.info("Loading MNIST data") fname = datapath(fname) if fname[-3:] == ".gz": open_func = gzip.open else: open_func = open with open_func(fname) as f: (train_x, train_y), (valid_x, valid_y), (test_x, test_y) = pickle.load(f) if which_set == 'train': self.X, self.Y = self.prepare(train_x, train_y, n_datapoints) elif which_set == 'valid': self.X, self.Y = self.prepare(valid_x, valid_y, n_datapoints) elif which_set == 'test': self.X, self.Y = self.prepare(test_x, test_y, n_datapoints) elif which_set == 'salakhutdinov_train': train_x = np.concatenate([train_x, valid_x]) train_y = np.concatenate([train_y, valid_y]) self.X, self.Y = self.prepare(train_x, train_y, n_datapoints) elif which_set == 'salakhutdinov_valid': train_x = np.concatenate([train_x, valid_x])[::-1] train_y = np.concatenate([train_y, valid_y])[::-1] self.X, self.Y = self.prepare(train_x, train_y, n_datapoints) else: raise ValueError("Unknown dataset %s" % which_set) self.n_datapoints = self.X.shape[0]
14,424
[ 0.005775899160653353, 0.020008139312267303, 0.027309922501444817, 0.005267270375043154, -0.019409017637372017, -0.010734247975051403, -0.011158624663949013, -0.02068214863538742, -0.06829977035522461, 0.019783468917012215, -0.00045870186295360327, -0.03152873367071152, 0.005339039955288172, ...
17
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "data", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "meta", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "rescale", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "rotate", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "user_peak", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "nonlinear", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [{"_type": "Constant", "_fields": {"kind": null, "value": true}}, {"_type": "Constant", "_fields": {"kind": null, "value": false}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, {"_type": "Constant", "_fields": {"kind": null, "value": null}}], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "in basic_info"}}], "func": {"_type": "Name", "_fields": {"id": "print", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "shape", "value": {"_type": "Name", "_fields": {"id": "data", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "dims", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "dims", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "len", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "ndims", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "v"}}, "value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "MXG"}}, "value": {"_type": "Name", "_fields": {"id": "meta", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "mxg", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "shape", "value": {"_type": "Name", "_fields": {"id": "data", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "nt", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "nx", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "ny", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "nz", "ctx": {"_type": "Store", "_fields": {}}}}]}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "nt", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "nx", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "ny", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "print", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "ndims", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": 4}}]}}, "orelse": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "something with dimesions"}}], "func": {"_type": "Name", "_fields": {"id": "print", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}]}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mean", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mean", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mean", "value": {"_type": "Name", "_fields": {"id": "data", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "dc", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "max", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "max", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "max", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "data", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "abs", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, "keywords": []}}}}, "keywords": []}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "amp", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "v"}}, "value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "dt"}}, "value": {"_type": "Name", "_fields": {"id": "meta", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "dt", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Sub", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "amp", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "Name", "_fields": {"id": "dc", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "amp_o", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "amp_o", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "nx", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "Name", "_fields": {"id": "ny", "ctx": {"_type": "Load", "_fields": {}}}}}}, "right": {"_type": "Name", "_fields": {"id": "nz", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "repeat", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "fourDamp", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "nt", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "nx", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "ny", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "nz", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "reshape", "value": {"_type": "Name", "_fields": {"id": "fourDamp", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "fourDamp", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "dc", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "amp_o", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "old_div", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "dc_n", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "data", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "fourDamp", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "old_div", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "data_n", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "shape", "value": {"_type": "Name", "_fields": {"id": "data", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Name", "_fields": {"id": "print", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "data", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "gradient", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "dfdt", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "max", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "max", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "max", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "dfdt", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "abs", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, "keywords": []}}}}, "keywords": []}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "dfdt", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Dict", "_fields": {"keys": [{"_type": "Constant", "_fields": {"kind": null, "value": "amp"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "dc"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "amp_o"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "dfdt"}}], "values": [{"_type": "Name", "_fields": {"id": "amp", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "dc", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "amp_o", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "dfdt", "ctx": {"_type": "Load", "_fields": {}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "ave", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}], "test": {"_type": "Name", "_fields": {"id": "rescale", "ctx": {"_type": "Load", "_fields": {}}}}, "orelse": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "no rescaling"}}], "func": {"_type": "Name", "_fields": {"id": "print", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Dict", "_fields": {"keys": [{"_type": "Constant", "_fields": {"kind": null, "value": "amp"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "dc"}}], "values": [{"_type": "Name", "_fields": {"id": "amp", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "dc", "ctx": {"_type": "Load", "_fields": {}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "ave", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}]}}, {"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "max", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "max", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "max", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Slice", "_fields": {"step": null, "lower": {"_type": "Name", "_fields": {"id": "mxg", "ctx": {"_type": "Load", "_fields": {}}}}, "upper": {"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}, "right": {"_type": "Name", "_fields": {"id": "mxg", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}]}}, "value": {"_type": "Name", "_fields": {"id": "nonlinear", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Name", "_fields": {"id": "abs", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, "keywords": []}}}}, "keywords": []}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "nl", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "nl", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "dfdt", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "old_div", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "right": {"_type": "Name", "_fields": {"id": "dt", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "nl_norm", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Name", "_fields": {"id": "nl", "ctx": {"_type": "Load", "_fields": {}}}}, "targets": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "nl"}}, "value": {"_type": "Name", "_fields": {"id": "ave", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Name", "_fields": {"id": "nl_norm", "ctx": {"_type": "Load", "_fields": {}}}}, "targets": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "nl_norm"}}, "value": {"_type": "Name", "_fields": {"id": "ave", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "NotEq", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "nonlinear", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": null}}]}}, "orelse": []}}, {"_type": "If", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "rotate stuff"}}], "func": {"_type": "Name", "_fields": {"id": "print", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}], "test": {"_type": "Name", "_fields": {"id": "rotate", "ctx": {"_type": "Load", "_fields": {}}}}, "orelse": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "or not"}}], "func": {"_type": "Name", "_fields": {"id": "print", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}]}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "data", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "user_peak", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "fft_info", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "meta", "value": {"_type": "Name", "_fields": {"id": "meta", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "peaks_db", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Return", "_fields": {"value": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "peaks_db", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "ave", "ctx": {"_type": "Load", "_fields": {}}}}]}}}}], "name": "basic_info", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def basic_info(data,meta,rescale=True,rotate=False,user_peak=0,nonlinear=None): print('in basic_info') #from . import read_grid,parse_inp,read_inp,show dims = data.shape ndims = len(dims) mxg = meta['MXG']['v'] if ndims ==4: nt,nx,ny,nz = data.shape print(nt,nx,ny) else: print("something with dimesions") dc = data.mean(1).mean(1).mean(1) # there MUST be a way to indicate all axis at once amp = abs(data).max(1).max(1).max(1) dt = meta['dt']['v'] if rescale: amp_o = amp - dc fourDamp = np.repeat(amp_o,nx*ny*nz) fourDamp = fourDamp.reshape(nt,nx,ny,nz) dc_n = old_div(dc,amp_o) data_n = old_div(data,fourDamp) print(data.shape) dfdt = np.gradient(data)[0] dfdt = abs(dfdt).max(1).max(1).max(1) ave = {'amp':amp,'dc':dc,'amp_o':amp_o,'dfdt':dfdt} else: print("no rescaling") ave = {'amp':amp,'dc':dc} if nonlinear != None: #add nonlinear part if user provides nl = abs(nonlinear[:,mxg:-1.0*mxg,:,:]).max(1).max(1).max(1) nl_norm = (old_div(nl,dfdt)) *dt ave['nl'] =nl ave['nl_norm'] = nl_norm if rotate: print('rotate stuff') # will need to provide some grid geometry to do this one else: print('or not') #let's identify the dominant modes, for now at every [t,x] slice #if the data set is too large we can average over x peaks_db = fft_info(data,user_peak,meta=meta) #Nt X Nx X (# of loc. max) list of dict #print peaks[0]['gamma'] return peaks_db,ave
14,425
[ 0.010654892772436142, -0.01351489033550024, 0.023732371628284454, -0.02801676094532013, 0.025953076779842377, -0.015163594856858253, 0.01384014543145895, -0.005725603085011244, -0.006650896277278662, 0.008630462922155857, -0.013885008171200752, 0.01975080743432045, -0.0025305370800197124, ...
9
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "x", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "y", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "n_datapoints", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "shape", "value": {"_type": "Name", "_fields": {"id": "x", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "N", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assert", "_fields": {"msg": null, "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "N", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "shape", "value": {"_type": "Name", "_fields": {"id": "y", "ctx": {"_type": "Load", "_fields": {}}}}}}}}]}}}}, {"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Name", "_fields": {"id": "n_datapoints", "ctx": {"_type": "Load", "_fields": {}}}}, "targets": [{"_type": "Name", "_fields": {"id": "N", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "IsNot", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "n_datapoints", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": null}}]}}, "orelse": []}}, {"_type": "Assign", "_fields": {"value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": {"_type": "Name", "_fields": {"id": "N", "ctx": {"_type": "Load", "_fields": {}}}}}}, "value": {"_type": "Name", "_fields": {"id": "x", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "x", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": {"_type": "Name", "_fields": {"id": "N", "ctx": {"_type": "Load", "_fields": {}}}}}}, "value": {"_type": "Name", "_fields": {"id": "y", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "y", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "N", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 10}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "zeros", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "dtype", "value": {"_type": "Name", "_fields": {"id": "floatX", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "one_hot", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "For", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}, "targets": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "slice": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "n", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Name", "_fields": {"id": "n", "ctx": {"_type": "Load", "_fields": {}}}}, "value": {"_type": "Name", "_fields": {"id": "y", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "value": {"_type": "Name", "_fields": {"id": "one_hot", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}], "iter": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "N", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "xrange", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "orelse": [], "target": {"_type": "Name", "_fields": {"id": "n", "ctx": {"_type": "Store", "_fields": {}}}}, "type_comment": null}}, {"_type": "Return", "_fields": {"value": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "floatX", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "astype", "value": {"_type": "Name", "_fields": {"id": "x", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "floatX", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "astype", "value": {"_type": "Name", "_fields": {"id": "one_hot", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}]}}}}], "name": "prepare", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def prepare(self, x, y, n_datapoints): N = x.shape[0] assert N == y.shape[0] if n_datapoints is not None: N = n_datapoints x = x[:N] y = y[:N] one_hot = np.zeros((N, 10), dtype=floatX) for n in xrange(N): one_hot[n, y[n]] = 1. return x.astype(floatX), one_hot.astype(floatX)
14,426
[ -0.025614870712161064, -0.017867308109998703, 0.0707680955529213, -0.040642574429512024, -0.043634090572595596, -0.03304692357778549, 0.04052571579813957, 0.01586906611919403, -0.009687376208603382, 0.04828496649861336, 0.005261448677629232, -0.05730626359581947, -0.008115660399198532, 0.0...
11
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b2", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "Basic", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b2", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "Basic", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "b2", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "Basic", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b2", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "Basic", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "b2", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "Basic", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, {"_type": "Name", "_fields": {"id": "b2", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "instances", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "For", "_fields": {"body": [{"_type": "For", "_fields": {"body": [{"_type": "If", "_fields": {"body": [{"_type": "Assert", "_fields": {"msg": null, "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "b_j", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "matches", "value": {"_type": "Name", "_fields": {"id": "b_i", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "comparators": [{"_type": "Dict", "_fields": {"keys": [], "values": []}}]}}}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "i", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "Name", "_fields": {"id": "j", "ctx": {"_type": "Load", "_fields": {}}}}]}}, "orelse": [{"_type": "Assert", "_fields": {"msg": null, "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Is", "_fields": {}}], "left": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "b_j", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "matches", "value": {"_type": "Name", "_fields": {"id": "b_i", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": null}}]}}}}]}}], "iter": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "instances", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "enumerate", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "orelse": [], "target": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "j", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b_j", "ctx": {"_type": "Store", "_fields": {}}}}]}}, "type_comment": null}}], "iter": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "instances", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "enumerate", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "orelse": [], "target": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "i", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b_i", "ctx": {"_type": "Store", "_fields": {}}}}]}}, "type_comment": null}}, {"_type": "Assert", "_fields": {"msg": null, "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "match", "value": {"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "comparators": [{"_type": "Dict", "_fields": {"keys": [], "values": []}}]}}}}], "name": "test_matches_basic", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def test_matches_basic(): instances = [Basic(b1, b1, b2), Basic(b1, b2, b1), Basic(b2, b1, b1), Basic(b1, b2), Basic(b2, b1), b2, b1] for i, b_i in enumerate(instances): for j, b_j in enumerate(instances): if i == j: assert b_i.matches(b_j) == {} else: assert b_i.matches(b_j) is None assert b1.match(b1) == {}
14,427
[ 0.013266141526401043, -0.0469709150493145, 0.04412563145160675, -0.027599265798926353, -0.01815054751932621, -0.006034375634044409, 0.027101341634988785, 0.029448701068758965, -0.005628329701721668, 0.01374035608023405, 0.02286897972226143, -0.04746884107589722, -0.02170715481042862, 0.018...
9
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b2", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b3", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b21", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "Basic", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, {"_type": "Name", "_fields": {"id": "Basic", "ctx": {"_type": "Load", "_fields": {}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "instances", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "For", "_fields": {"body": [{"_type": "For", "_fields": {"body": [{"_type": "Assert", "_fields": {"msg": null, "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "b_i", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "Name", "_fields": {"id": "b_j", "ctx": {"_type": "Load", "_fields": {}}}}]}}, "comparators": [{"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "i", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "Name", "_fields": {"id": "j", "ctx": {"_type": "Load", "_fields": {}}}}]}}]}}}}, {"_type": "Assert", "_fields": {"msg": null, "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Compare", "_fields": {"ops": [{"_type": "NotEq", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "b_i", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "Name", "_fields": {"id": "b_j", "ctx": {"_type": "Load", "_fields": {}}}}]}}, "comparators": [{"_type": "Compare", "_fields": {"ops": [{"_type": "NotEq", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "i", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "Name", "_fields": {"id": "j", "ctx": {"_type": "Load", "_fields": {}}}}]}}]}}}}], "iter": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "instances", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "enumerate", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "orelse": [], "target": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "j", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b_j", "ctx": {"_type": "Store", "_fields": {}}}}]}}, "type_comment": null}}], "iter": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "instances", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "enumerate", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "orelse": [], "target": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "i", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b_i", "ctx": {"_type": "Store", "_fields": {}}}}]}}, "type_comment": null}}, {"_type": "Assert", "_fields": {"msg": null, "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "NotEq", "_fields": {}}], "left": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "Basic", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "comparators": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": []}}]}}}}, {"_type": "Assert", "_fields": {"msg": null, "test": {"_type": "UnaryOp", "_fields": {"op": {"_type": "Not", "_fields": {}}, "operand": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "Basic", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "comparators": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": []}}]}}}}}}, {"_type": "Assert", "_fields": {"msg": null, "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "NotEq", "_fields": {}}], "left": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "Basic", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": 0}}]}}}}, {"_type": "Assert", "_fields": {"msg": null, "test": {"_type": "UnaryOp", "_fields": {"op": {"_type": "Not", "_fields": {}}, "operand": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "Basic", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": 0}}]}}}}}}], "name": "test_equality", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def test_equality(): instances = [b1, b2, b3, b21, Basic(b1, b1, b1), Basic] for i, b_i in enumerate(instances): for j, b_j in enumerate(instances): assert (b_i == b_j) == (i == j) assert (b_i != b_j) == (i != j) assert Basic() != [] assert not(Basic() == []) assert Basic() != 0 assert not(Basic() == 0)
14,428
[ 0.00013797708379570395, -0.007074355613440275, 0.05917636305093765, -0.02307232841849327, -0.040857505053281784, -0.002626509638503194, 0.020801087841391563, 0.020453575998544693, 0.026857728138566017, 0.01730114221572876, -0.0004440864722710103, -0.048602063208818436, 0.012932417914271355, ...
9
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assert", "_fields": {"msg": null, "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "b2", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "subs", "value": {"_type": "Name", "_fields": {"id": "b21", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "comparators": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "Basic", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}]}}}}, {"_type": "Assert", "_fields": {"msg": null, "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "b2", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b21", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "subs", "value": {"_type": "Name", "_fields": {"id": "b21", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "comparators": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "b21", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "Basic", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}]}}}}, {"_type": "Assert", "_fields": {"msg": null, "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "b2", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "subs", "value": {"_type": "Name", "_fields": {"id": "b3", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "comparators": [{"_type": "Name", "_fields": {"id": "b2", "ctx": {"_type": "Load", "_fields": {}}}}]}}}}, {"_type": "Assert", "_fields": {"msg": null, "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "b2", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}]}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b2", "ctx": {"_type": "Load", "_fields": {}}}}]}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "subs", "value": {"_type": "Name", "_fields": {"id": "b21", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "comparators": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "b2", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b2", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "Basic", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}]}}}}, {"_type": "Assert", "_fields": {"msg": null, "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Call", "_fields": {"args": [{"_type": "Dict", "_fields": {"keys": [{"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b2", "ctx": {"_type": "Load", "_fields": {}}}}], "values": [{"_type": "Name", "_fields": {"id": "b2", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "subs", "value": {"_type": "Name", "_fields": {"id": "b21", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "comparators": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "b2", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b2", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "Basic", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}]}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "ValueError", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Lambda", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "bad arg"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "subs", "value": {"_type": "Name", "_fields": {"id": "b21", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "func": {"_type": "Name", "_fields": {"id": "raises", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "ValueError", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Lambda", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b2", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b3", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "subs", "value": {"_type": "Name", "_fields": {"id": "b21", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "func": {"_type": "Name", "_fields": {"id": "raises", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}], "name": "test_subs", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def test_subs(): assert b21.subs(b2, b1) == Basic(b1, b1) assert b21.subs(b2, b21) == Basic(b21, b1) assert b3.subs(b2, b1) == b2 assert b21.subs([(b2, b1), (b1, b2)]) == Basic(b2, b2) assert b21.subs({b1: b2, b2: b1}) == Basic(b2, b2) raises(ValueError, lambda: b21.subs('bad arg')) raises(ValueError, lambda: b21.subs(b1, b2, b3))
14,429
[ 0.011759401299059391, -0.018046729266643524, 0.007781956810504198, -0.025519877672195435, -0.03834157809615135, -0.0066640726290643215, -0.0014452205505222082, 0.006941999774426222, 0.020665418356657028, 0.01593448407948017, 0.012969927862286568, -0.03569818288087845, -0.002198711736127734, ...
9
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assert", "_fields": {"msg": null, "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Call", "_fields": {"args": [{"_type": "Dict", "_fields": {"keys": [{"_type": "Name", "_fields": {"id": "b2", "ctx": {"_type": "Load", "_fields": {}}}}], "values": [{"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "xreplace", "value": {"_type": "Name", "_fields": {"id": "b21", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "comparators": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "Basic", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}]}}}}, {"_type": "Assert", "_fields": {"msg": null, "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Call", "_fields": {"args": [{"_type": "Dict", "_fields": {"keys": [{"_type": "Name", "_fields": {"id": "b2", "ctx": {"_type": "Load", "_fields": {}}}}], "values": [{"_type": "Name", "_fields": {"id": "b21", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "xreplace", "value": {"_type": "Name", "_fields": {"id": "b21", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "comparators": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "b21", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "Basic", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}]}}}}, {"_type": "Assert", "_fields": {"msg": null, "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Call", "_fields": {"args": [{"_type": "Dict", "_fields": {"keys": [{"_type": "Name", "_fields": {"id": "b2", "ctx": {"_type": "Load", "_fields": {}}}}], "values": [{"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "xreplace", "value": {"_type": "Name", "_fields": {"id": "b3", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "comparators": [{"_type": "Name", "_fields": {"id": "b2", "ctx": {"_type": "Load", "_fields": {}}}}]}}}}, {"_type": "Assert", "_fields": {"msg": null, "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Call", "_fields": {"args": [{"_type": "Dict", "_fields": {"keys": [{"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b2", "ctx": {"_type": "Load", "_fields": {}}}}], "values": [{"_type": "Name", "_fields": {"id": "b2", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "xreplace", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b2", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "Basic", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, "keywords": []}}, "comparators": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "b2", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "Basic", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}]}}}}, {"_type": "Assert", "_fields": {"msg": null, "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Call", "_fields": {"args": [{"_type": "Dict", "_fields": {"keys": [{"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}], "values": [{"_type": "Name", "_fields": {"id": "b2", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "xreplace", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "Atom", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, "keywords": []}}, "comparators": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "Atom", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}]}}}}, {"_type": "Assert", "_fields": {"msg": null, "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Call", "_fields": {"args": [{"_type": "Dict", "_fields": {"keys": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "Atom", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}], "values": [{"_type": "Name", "_fields": {"id": "b2", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "xreplace", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "Atom", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, "keywords": []}}, "comparators": [{"_type": "Name", "_fields": {"id": "b2", "ctx": {"_type": "Load", "_fields": {}}}}]}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "TypeError", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Lambda", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "xreplace", "value": {"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "func": {"_type": "Name", "_fields": {"id": "raises", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "TypeError", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Lambda", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b2", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "xreplace", "value": {"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "func": {"_type": "Name", "_fields": {"id": "raises", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}], "name": "test_xreplace", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def test_xreplace(): assert b21.xreplace({b2: b1}) == Basic(b1, b1) assert b21.xreplace({b2: b21}) == Basic(b21, b1) assert b3.xreplace({b2: b1}) == b2 assert Basic(b1, b2).xreplace({b1: b2, b2: b1}) == Basic(b2, b1) assert Atom(b1).xreplace({b1: b2}) == Atom(b1) assert Atom(b1).xreplace({Atom(b1): b2}) == b2 raises(TypeError, lambda: b1.xreplace()) raises(TypeError, lambda: b1.xreplace([b1, b2]))
14,430
[ 0.02998366579413414, -0.006049228832125664, 0.02405041642487049, -0.006952645722776651, 0.04390116408467293, 0.03242533281445503, 0.03152191638946533, -0.0026049530133605003, 0.018935123458504677, -0.012342624366283417, 0.02046116627752781, -0.04407208040356636, 0.011634541675448418, 0.010...
9
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Global", "_fields": {"names": ["instantiated"]}}, {"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "targets": [{"_type": "Name", "_fields": {"id": "instantiated", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "ClassDef", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "cls", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Global", "_fields": {"names": ["instantiated"]}}, {"_type": "AugAssign", "_fields": {"op": {"_type": "Add", "_fields": {}}, "value": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}, "target": {"_type": "Name", "_fields": {"id": "instantiated", "ctx": {"_type": "Store", "_fields": {}}}}}}, {"_type": "Return", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "cls", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "__new__", "value": {"_type": "Name", "_fields": {"id": "Basic", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "name": "__new__", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "name": "MySingleton", "bases": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "Singleton", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "Basic", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "with_metaclass", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}], "keywords": [], "type_params": [], "decorator_list": []}}, {"_type": "Assert", "_fields": {"msg": null, "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "instantiated", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}]}}}}, {"_type": "Assert", "_fields": {"msg": null, "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "IsNot", "_fields": {}}], "left": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "MySingleton", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "comparators": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "Basic", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}]}}}}, {"_type": "Assert", "_fields": {"msg": null, "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Is", "_fields": {}}], "left": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "MySingleton", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "comparators": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "MySingleton", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}]}}}}, {"_type": "Assert", "_fields": {"msg": null, "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Is", "_fields": {}}], "left": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "MySingleton", "value": {"_type": "Name", "_fields": {"id": "S", "ctx": {"_type": "Load", "_fields": {}}}}}}, "comparators": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "MySingleton", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}]}}}}, {"_type": "Assert", "_fields": {"msg": null, "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "instantiated", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}]}}}}, {"_type": "ClassDef", "_fields": {"body": [{"_type": "Pass", "_fields": {}}], "name": "MySingleton_sub", "bases": [{"_type": "Name", "_fields": {"id": "MySingleton", "ctx": {"_type": "Load", "_fields": {}}}}], "keywords": [], "type_params": [], "decorator_list": []}}, {"_type": "Assert", "_fields": {"msg": null, "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "instantiated", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": 2}}]}}}}, {"_type": "Assert", "_fields": {"msg": null, "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "IsNot", "_fields": {}}], "left": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "MySingleton_sub", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "comparators": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "MySingleton", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}]}}}}, {"_type": "Assert", "_fields": {"msg": null, "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Is", "_fields": {}}], "left": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "MySingleton_sub", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "comparators": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "MySingleton_sub", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}]}}}}], "name": "test_Singleton", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def test_Singleton(): global instantiated instantiated = 0 class MySingleton(with_metaclass(Singleton, Basic)): def __new__(cls): global instantiated instantiated += 1 return Basic.__new__(cls) assert instantiated == 1 assert MySingleton() is not Basic() assert MySingleton() is MySingleton() assert S.MySingleton is MySingleton() assert instantiated == 1 class MySingleton_sub(MySingleton): pass assert instantiated == 2 assert MySingleton_sub() is not MySingleton() assert MySingleton_sub() is MySingleton_sub()
14,431
[ 0.048912353813648224, 0.012876177206635475, 0.028711551800370216, -0.037417951971292496, -0.025996915996074677, 0.017914149910211563, 0.008327328599989414, 0.019222555682063103, -0.05395032837986946, 0.03494787588715553, 0.003998585045337677, -0.015101689845323563, 0.003631742438301444, -0...
11
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "b21", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b3", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "Basic", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "expr", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assert", "_fields": {"msg": null, "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "expr", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "preorder_traversal", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}], "func": {"_type": "Name", "_fields": {"id": "list", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "comparators": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "expr", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b21", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b2", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b3", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b2", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}]}}]}}}}, {"_type": "Assert", "_fields": {"msg": null, "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": "abc"}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": "d"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "ef"}}]}}]}}], "func": {"_type": "Name", "_fields": {"id": "preorder_traversal", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}], "func": {"_type": "Name", "_fields": {"id": "list", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "comparators": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": "abc"}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": "d"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "ef"}}]}}]}}, {"_type": "Constant", "_fields": {"kind": null, "value": "abc"}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": "d"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "ef"}}]}}, {"_type": "Constant", "_fields": {"kind": null, "value": "d"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "ef"}}]}}]}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": []}}, "targets": [{"_type": "Name", "_fields": {"id": "result", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "expr", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "preorder_traversal", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "pt", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "For", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "i", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "append", "value": {"_type": "Name", "_fields": {"id": "result", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "If", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "skip", "value": {"_type": "Name", "_fields": {"id": "pt", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "i", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "Name", "_fields": {"id": "b2", "ctx": {"_type": "Load", "_fields": {}}}}]}}, "orelse": []}}], "iter": {"_type": "Name", "_fields": {"id": "pt", "ctx": {"_type": "Load", "_fields": {}}}}, "orelse": [], "target": {"_type": "Name", "_fields": {"id": "i", "ctx": {"_type": "Store", "_fields": {}}}}, "type_comment": null}}, {"_type": "Assert", "_fields": {"msg": null, "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "result", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "expr", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b21", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b2", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b1", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b3", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "b2", "ctx": {"_type": "Load", "_fields": {}}}}]}}]}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "w:z"}}], "func": {"_type": "Name", "_fields": {"id": "symbols", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "w", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "x", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "y", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "z", "ctx": {"_type": "Store", "_fields": {}}}}]}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "z", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "w", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "x", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "Name", "_fields": {"id": "y", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "expr", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assert", "_fields": {"msg": null, "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "expr", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Name", "_fields": {"id": "preorder_traversal", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "keys", "value": {"_type": "Name", "_fields": {"id": "default_sort_key", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}], "func": {"_type": "Name", "_fields": {"id": "list", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "comparators": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "w", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "x", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "Name", "_fields": {"id": "y", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "right": {"_type": "Name", "_fields": {"id": "z", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, {"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "w", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "x", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "Name", "_fields": {"id": "y", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "right": {"_type": "Name", "_fields": {"id": "z", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Name", "_fields": {"id": "z", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "w", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "x", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "Name", "_fields": {"id": "y", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Name", "_fields": {"id": "w", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "x", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "Name", "_fields": {"id": "y", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Name", "_fields": {"id": "x", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "y", "ctx": {"_type": "Load", "_fields": {}}}}]}}]}}}}, {"_type": "Assert", "_fields": {"msg": null, "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "x", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "Name", "_fields": {"id": "y", "ctx": {"_type": "Load", "_fields": {}}}}}}, "right": {"_type": "Name", "_fields": {"id": "z", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Name", "_fields": {"id": "preorder_traversal", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "keys", "value": {"_type": "Constant", "_fields": {"kind": null, "value": true}}}}]}}], "func": {"_type": "Name", "_fields": {"id": "list", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "comparators": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "z", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "x", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "Name", "_fields": {"id": "y", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Name", "_fields": {"id": "z", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "x", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "Name", "_fields": {"id": "y", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Name", "_fields": {"id": "x", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "y", "ctx": {"_type": "Load", "_fields": {}}}}]}}]}}}}], "name": "test_preorder_traversal", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def test_preorder_traversal(): expr = Basic(b21, b3) assert list( preorder_traversal(expr)) == [expr, b21, b2, b1, b1, b3, b2, b1] assert list(preorder_traversal(('abc', ('d', 'ef')))) == [ ('abc', ('d', 'ef')), 'abc', ('d', 'ef'), 'd', 'ef'] result = [] pt = preorder_traversal(expr) for i in pt: result.append(i) if i == b2: pt.skip() assert result == [expr, b21, b2, b1, b3, b2] w, x, y, z = symbols('w:z') expr = z + w*(x + y) assert list(preorder_traversal([expr], keys=default_sort_key)) == \ [[w*(x + y) + z], w*(x + y) + z, z, w*(x + y), w, x + y, x, y] assert list(preorder_traversal((x + y)*z, keys=True)) == \ [z*(x + y), z, x + y, x, y]
14,432
[ 0.0401628315448761, -0.0141183752566576, -0.0026526760775595903, 0.0044534895569086075, 0.0394863523542881, 0.014907601289451122, -0.03437517583370209, -0.04041337966918945, 0.03570307791233063, 0.000743422657251358, -0.007804567925632, -0.07295955717563629, 0.015045402571558952, 0.0014954...
10
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "x y"}}], "func": {"_type": "Name", "_fields": {"id": "symbols", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "x", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "y", "ctx": {"_type": "Store", "_fields": {}}}}]}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "TypeError", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Lambda", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": {"_type": "Call", "_fields": {"args": [{"_type": "Dict", "_fields": {"keys": [{"_type": "Name", "_fields": {"id": "x", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "x", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "sin", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}], "values": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2}}]}}], "func": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "x", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "sin", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "keywords": []}}}}], "func": {"_type": "Name", "_fields": {"id": "raises", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "TypeError", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Lambda", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}], "func": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "x", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "sin", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "keywords": []}}}}], "func": {"_type": "Name", "_fields": {"id": "raises", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Assert", "_fields": {"msg": null, "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "rcall", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "x", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "sin", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, "keywords": []}}, "comparators": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "x", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "sin", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}]}}}}, {"_type": "Assert", "_fields": {"msg": null, "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "rcall", "value": {"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}, "right": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "x", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "sin", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}}}, "keywords": []}}, "comparators": [{"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}, "right": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "x", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "sin", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}]}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "x", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "Constant", "_fields": {"kind": null, "value": 2}}, "right": {"_type": "Name", "_fields": {"id": "x", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Name", "_fields": {"id": "Lambda", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "l", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assert", "_fields": {"msg": null, "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "y", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "rcall", "value": {"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "l", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "Name", "_fields": {"id": "x", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}, "comparators": [{"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "Constant", "_fields": {"kind": null, "value": 2}}, "right": {"_type": "Name", "_fields": {"id": "y", "ctx": {"_type": "Load", "_fields": {}}}}}}, "right": {"_type": "Name", "_fields": {"id": "x", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}}}, {"_type": "Assert", "_fields": {"msg": null, "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 2}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "rcall", "value": {"_type": "BinOp", "_fields": {"op": {"_type": "Pow", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "x", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "Name", "_fields": {"id": "l", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}, "comparators": [{"_type": "BinOp", "_fields": {"op": {"_type": "Pow", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "x", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": 4}}}}]}}}}, {"_type": "Assert", "_fields": {"msg": null, "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Eq", "_fields": {}}], "left": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "x", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "rcall", "value": {"_type": "BinOp", "_fields": {"op": {"_type": "BitAnd", "_fields": {}}, "left": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "real", "value": {"_type": "Name", "_fields": {"id": "Q", "ctx": {"_type": "Load", "_fields": {}}}}}}, "right": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "positive", "value": {"_type": "Name", "_fields": {"id": "Q", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": []}}, "comparators": [{"_type": "BinOp", "_fields": {"op": {"_type": "BitAnd", "_fields": {}}, "left": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "x", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "real", "value": {"_type": "Name", "_fields": {"id": "Q", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "right": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "x", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "positive", "value": {"_type": "Name", "_fields": {"id": "Q", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}]}}}}], "name": "test_call", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def test_call(): x, y = symbols('x y') # See the long history of this in issues 5026 and 5105. raises(TypeError, lambda: sin(x)({ x : 1, sin(x) : 2})) raises(TypeError, lambda: sin(x)(1)) # No effect as there are no callables assert sin(x).rcall(1) == sin(x) assert (1 + sin(x)).rcall(1) == 1 + sin(x) # Effect in the pressence of callables l = Lambda(x, 2*x) assert (l + x).rcall(y) == 2*y + x assert (x**l).rcall(2) == x**4 # TODO UndefinedFunction does not subclass Expr #f = Function('f') #assert (2*f)(x) == 2*f(x) assert (Q.real & Q.positive).rcall(x) == Q.real(x) & Q.positive(x)
14,433
[ 0.07399525493383408, -0.0012415357632562518, 0.05920508876442909, -0.037575021386146545, 0.03344443440437317, -0.017166366800665855, 0.025338711217045784, -0.001319955918006599, 0.019031792879104614, 0.01443484891206026, -0.012158583849668503, 0.018254531547427177, 0.012158583849668503, -0...
9
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": "TEXT"}}, "targets": [{"_type": "Name", "_fields": {"id": "TEXT", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Dict", "_fields": {"keys": [{"_type": "Constant", "_fields": {"kind": null, "value": "textPayload"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "resource"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "logName"}}], "values": [{"_type": "Name", "_fields": {"id": "TEXT", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Dict", "_fields": {"keys": [{"_type": "Constant", "_fields": {"kind": null, "value": "type"}}], "values": [{"_type": "Constant", "_fields": {"kind": null, "value": "global"}}]}}, {"_type": "BinOp", "_fields": {"op": {"_type": "Mod", "_fields": {}}, "left": {"_type": "Constant", "_fields": {"kind": null, "value": "projects/%s/logs/%s"}}, "right": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "PROJECT", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "LOGGER_NAME", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "ENTRY", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Dict", "_fields": {"keys": [{"_type": "Constant", "_fields": {"kind": null, "value": "entries"}}], "values": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "ENTRY", "ctx": {"_type": "Load", "_fields": {}}}}]}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "SENT", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Dict", "_fields": {"keys": [], "values": []}}], "func": {"_type": "Name", "_fields": {"id": "_Connection", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "_Client", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "client", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "client", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_make_one", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "api", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "ENTRY", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "write_entries", "value": {"_type": "Name", "_fields": {"id": "api", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "method"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_called_with", "value": {"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": "POST"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Mod", "_fields": {}}, "left": {"_type": "Constant", "_fields": {"kind": null, "value": "/%s"}}, "right": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "WRITE_ENTRIES_PATH", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "path", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "path"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_called_with", "value": {"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Name", "_fields": {"id": "path", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "data"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_called_with", "value": {"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Name", "_fields": {"id": "SENT", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "name": "test_write_entries_single", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def test_write_entries_single(self): TEXT = 'TEXT' ENTRY = { 'textPayload': TEXT, 'resource': { 'type': 'global', }, 'logName': 'projects/%s/logs/%s' % ( self.PROJECT, self.LOGGER_NAME), } SENT = { 'entries': [ENTRY], } conn = _Connection({}) client = _Client(conn) api = self._make_one(client) api.write_entries([ENTRY]) self.assertEqual(conn._called_with['method'], 'POST') path = '/%s' % self.WRITE_ENTRIES_PATH self.assertEqual(conn._called_with['path'], path) self.assertEqual(conn._called_with['data'], SENT)
14,434
[ 0.04888523742556572, -0.0027449082117527723, 0.06065816059708595, -0.04520619660615921, 0.023189445957541466, -0.008841191418468952, 0.02837459184229374, -0.015900349244475365, 0.0126581946387887, 0.024097707122564316, -0.007059156894683838, 0.00877795834094286, -0.013198553584516048, -0.0...
8
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": "TEXT"}}, "targets": [{"_type": "Name", "_fields": {"id": "TEXT", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Mod", "_fields": {}}, "left": {"_type": "Constant", "_fields": {"kind": null, "value": "projects/%s/logs/%s"}}, "right": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "PROJECT", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "LOGGER_NAME", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}}}, "targets": [{"_type": "Name", "_fields": {"id": "LOG_NAME", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Dict", "_fields": {"keys": [{"_type": "Constant", "_fields": {"kind": null, "value": "type"}}], "values": [{"_type": "Constant", "_fields": {"kind": null, "value": "global"}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "RESOURCE", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Dict", "_fields": {"keys": [{"_type": "Constant", "_fields": {"kind": null, "value": "baz"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "spam"}}], "values": [{"_type": "Constant", "_fields": {"kind": null, "value": "qux"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "eggs"}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "LABELS", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Dict", "_fields": {"keys": [{"_type": "Constant", "_fields": {"kind": null, "value": "textPayload"}}], "values": [{"_type": "Name", "_fields": {"id": "TEXT", "ctx": {"_type": "Load", "_fields": {}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "ENTRY1", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Dict", "_fields": {"keys": [{"_type": "Constant", "_fields": {"kind": null, "value": "jsonPayload"}}], "values": [{"_type": "Dict", "_fields": {"keys": [{"_type": "Constant", "_fields": {"kind": null, "value": "foo"}}], "values": [{"_type": "Constant", "_fields": {"kind": null, "value": "bar"}}]}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "ENTRY2", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Dict", "_fields": {"keys": [{"_type": "Constant", "_fields": {"kind": null, "value": "logName"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "resource"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "labels"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "entries"}}], "values": [{"_type": "Name", "_fields": {"id": "LOG_NAME", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "RESOURCE", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "LABELS", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "ENTRY1", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "ENTRY2", "ctx": {"_type": "Load", "_fields": {}}}}]}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "SENT", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Dict", "_fields": {"keys": [], "values": []}}], "func": {"_type": "Name", "_fields": {"id": "_Connection", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "_Client", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "client", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "client", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_make_one", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "api", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "ENTRY1", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "ENTRY2", "ctx": {"_type": "Load", "_fields": {}}}}]}}, {"_type": "Name", "_fields": {"id": "LOG_NAME", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "RESOURCE", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "LABELS", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "write_entries", "value": {"_type": "Name", "_fields": {"id": "api", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "method"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_called_with", "value": {"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": "POST"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Mod", "_fields": {}}, "left": {"_type": "Constant", "_fields": {"kind": null, "value": "/%s"}}, "right": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "WRITE_ENTRIES_PATH", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "path", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "path"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_called_with", "value": {"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Name", "_fields": {"id": "path", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "data"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_called_with", "value": {"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Name", "_fields": {"id": "SENT", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "name": "test_write_entries_multiple", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def test_write_entries_multiple(self): TEXT = 'TEXT' LOG_NAME = 'projects/%s/logs/%s' % (self.PROJECT, self.LOGGER_NAME) RESOURCE = { 'type': 'global', } LABELS = { 'baz': 'qux', 'spam': 'eggs', } ENTRY1 = { 'textPayload': TEXT, } ENTRY2 = { 'jsonPayload': {'foo': 'bar'}, } SENT = { 'logName': LOG_NAME, 'resource': RESOURCE, 'labels': LABELS, 'entries': [ENTRY1, ENTRY2], } conn = _Connection({}) client = _Client(conn) api = self._make_one(client) api.write_entries([ENTRY1, ENTRY2], LOG_NAME, RESOURCE, LABELS) self.assertEqual(conn._called_with['method'], 'POST') path = '/%s' % self.WRITE_ENTRIES_PATH self.assertEqual(conn._called_with['path'], path) self.assertEqual(conn._called_with['data'], SENT)
14,435
[ 0.04221932217478752, 0.011905848979949951, 0.02786475233733654, -0.07688138633966446, 0.009926818311214447, 0.03696301579475403, 0.016486644744873047, 0.016877174377441406, 0.04627237468957901, 0.019526436924934387, 0.009214366786181927, -0.02645040489733219, -0.01471343357115984, -0.04335...
8
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Mod", "_fields": {}}, "left": {"_type": "Constant", "_fields": {"kind": null, "value": "/projects/%s/logs/%s"}}, "right": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "PROJECT", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "LOGGER_NAME", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}}}, "targets": [{"_type": "Name", "_fields": {"id": "path", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Dict", "_fields": {"keys": [], "values": []}}], "func": {"_type": "Name", "_fields": {"id": "_Connection", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "_Client", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "client", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "client", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_make_one", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "api", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "PROJECT", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "LOGGER_NAME", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "logger_delete", "value": {"_type": "Name", "_fields": {"id": "api", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "method"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_called_with", "value": {"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": "DELETE"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "path"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_called_with", "value": {"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Name", "_fields": {"id": "path", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "name": "test_logger_delete", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def test_logger_delete(self): path = '/projects/%s/logs/%s' % (self.PROJECT, self.LOGGER_NAME) conn = _Connection({}) client = _Client(conn) api = self._make_one(client) api.logger_delete(self.PROJECT, self.LOGGER_NAME) self.assertEqual(conn._called_with['method'], 'DELETE') self.assertEqual(conn._called_with['path'], path)
14,436
[ -0.0480707585811615, -0.0057499464601278305, 0.033668797463178635, -0.017713448032736778, 0.024541134014725685, -0.010903825052082539, -0.028948422521352768, 0.031212275847792625, 0.0017972346395254135, -0.015473677776753902, 0.0076585677452385426, -0.02192806825041771, -0.027069905772805214...
8
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Dict", "_fields": {"keys": [{"_type": "Constant", "_fields": {"kind": null, "value": "name"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "filter"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "destination"}}], "values": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "SINK_PATH", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "FILTER", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "DESTINATION_URI", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "RESPONSE", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "RESPONSE", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "_Connection", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "_Client", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "client", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "client", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_make_one", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "api", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "PROJECT", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "SINK_NAME", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sink_get", "value": {"_type": "Name", "_fields": {"id": "api", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "response", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "response", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "RESPONSE", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "method"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_called_with", "value": {"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": "GET"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Mod", "_fields": {}}, "left": {"_type": "Constant", "_fields": {"kind": null, "value": "/projects/%s/sinks/%s"}}, "right": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "PROJECT", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "SINK_NAME", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}}}, "targets": [{"_type": "Name", "_fields": {"id": "path", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "path"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_called_with", "value": {"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Name", "_fields": {"id": "path", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "name": "test_sink_get_hit", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def test_sink_get_hit(self): RESPONSE = { 'name': self.SINK_PATH, 'filter': self.FILTER, 'destination': self.DESTINATION_URI, } conn = _Connection(RESPONSE) client = _Client(conn) api = self._make_one(client) response = api.sink_get(self.PROJECT, self.SINK_NAME) self.assertEqual(response, RESPONSE) self.assertEqual(conn._called_with['method'], 'GET') path = '/projects/%s/sinks/%s' % (self.PROJECT, self.SINK_NAME) self.assertEqual(conn._called_with['path'], path)
14,437
[ -0.005656594876199961, 0.0074325366877019405, -0.0043561942875385284, 0.0004792107501998544, 0.009845469146966934, -0.04847000166773796, 0.025479627773165703, 0.005260310135781765, -0.010814164765179157, -0.020947307348251343, 0.015710480511188507, 0.005213343072682619, -0.03393369913101196,...
8
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Dict", "_fields": {"keys": [{"_type": "Constant", "_fields": {"kind": null, "value": "name"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "filter"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "destination"}}], "values": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "SINK_NAME", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "FILTER", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "DESTINATION_URI", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "sent", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "copy", "value": {"_type": "Name", "_fields": {"id": "sent", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "after_create", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "WRITER_IDENTITY", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "writerIdentity"}}, "value": {"_type": "Name", "_fields": {"id": "after_create", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "after_create", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "_Connection", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "_Client", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "client", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "client", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_make_one", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "api", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "PROJECT", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "SINK_NAME", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "FILTER", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "DESTINATION_URI", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sink_create", "value": {"_type": "Name", "_fields": {"id": "api", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "unique_writer_identity", "value": {"_type": "Constant", "_fields": {"kind": null, "value": true}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "returned", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "returned", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "after_create", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Mod", "_fields": {}}, "left": {"_type": "Constant", "_fields": {"kind": null, "value": "/projects/%s/sinks"}}, "right": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "PROJECT", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}}}, "targets": [{"_type": "Name", "_fields": {"id": "path", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Dict", "_fields": {"keys": [{"_type": "Constant", "_fields": {"kind": null, "value": "method"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "path"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "data"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "query_params"}}], "values": [{"_type": "Constant", "_fields": {"kind": null, "value": "POST"}}, {"_type": "Name", "_fields": {"id": "path", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "sent", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Dict", "_fields": {"keys": [{"_type": "Constant", "_fields": {"kind": null, "value": "uniqueWriterIdentity"}}], "values": [{"_type": "Constant", "_fields": {"kind": null, "value": true}}]}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "expected", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_called_with", "value": {"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Name", "_fields": {"id": "expected", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "name": "test_sink_create_ok", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def test_sink_create_ok(self): sent = { 'name': self.SINK_NAME, 'filter': self.FILTER, 'destination': self.DESTINATION_URI, } after_create = sent.copy() after_create['writerIdentity'] = self.WRITER_IDENTITY conn = _Connection(after_create) client = _Client(conn) api = self._make_one(client) returned = api.sink_create( self.PROJECT, self.SINK_NAME, self.FILTER, self.DESTINATION_URI, unique_writer_identity=True, ) self.assertEqual(returned, after_create) path = '/projects/%s/sinks' % (self.PROJECT,) expected = { 'method': 'POST', 'path': path, 'data': sent, 'query_params': {'uniqueWriterIdentity': True}, } self.assertEqual(conn._called_with, expected)
14,438
[ 0.011534676887094975, 0.011254164390265942, 0.04981903359293938, -0.027961494401097298, 0.011147569864988327, 0.01524866372346878, -0.015136458911001682, 0.03889026492834091, 0.004639678169041872, -0.03538946807384491, 0.02661503292620182, -0.03671348839998245, -0.03639931231737137, 0.0230...
8
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Dict", "_fields": {"keys": [], "values": []}}], "func": {"_type": "Name", "_fields": {"id": "_Connection", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "_Client", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "client", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "client", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_make_one", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "api", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "PROJECT", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "SINK_NAME", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sink_delete", "value": {"_type": "Name", "_fields": {"id": "api", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "method"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_called_with", "value": {"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": "DELETE"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Mod", "_fields": {}}, "left": {"_type": "Constant", "_fields": {"kind": null, "value": "/projects/%s/sinks/%s"}}, "right": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "PROJECT", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "SINK_NAME", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}}}, "targets": [{"_type": "Name", "_fields": {"id": "path", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "path"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_called_with", "value": {"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Name", "_fields": {"id": "path", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "name": "test_sink_delete_hit", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def test_sink_delete_hit(self): conn = _Connection({}) client = _Client(conn) api = self._make_one(client) api.sink_delete(self.PROJECT, self.SINK_NAME) self.assertEqual(conn._called_with['method'], 'DELETE') path = '/projects/%s/sinks/%s' % (self.PROJECT, self.SINK_NAME) self.assertEqual(conn._called_with['path'], path)
14,439
[ -0.0029958500526845455, -0.003953317645937204, 0.00868947058916092, -0.012862584553658962, 0.0006447099731303751, 0.005311235785484314, 0.018739869818091393, 0.011826833710074425, -0.021064288914203644, -0.015524224378168583, 0.019546793773770332, 0.008846038021147251, -0.07033473253250122, ...
8
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Dict", "_fields": {"keys": [{"_type": "Constant", "_fields": {"kind": null, "value": "name"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "filter"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "destination"}}], "values": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "SINK_NAME", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "FILTER", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "DESTINATION_URI", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "sent", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "copy", "value": {"_type": "Name", "_fields": {"id": "sent", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "after_update", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "WRITER_IDENTITY", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "writerIdentity"}}, "value": {"_type": "Name", "_fields": {"id": "after_update", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "after_update", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "_Connection", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "_Client", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "client", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "client", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_make_one", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "api", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "PROJECT", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "SINK_NAME", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "FILTER", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "DESTINATION_URI", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sink_update", "value": {"_type": "Name", "_fields": {"id": "api", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "unique_writer_identity", "value": {"_type": "Constant", "_fields": {"kind": null, "value": true}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "returned", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "returned", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "after_update", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Mod", "_fields": {}}, "left": {"_type": "Constant", "_fields": {"kind": null, "value": "/projects/%s/sinks/%s"}}, "right": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "PROJECT", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "SINK_NAME", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}}}, "targets": [{"_type": "Name", "_fields": {"id": "path", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Dict", "_fields": {"keys": [{"_type": "Constant", "_fields": {"kind": null, "value": "method"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "path"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "data"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "query_params"}}], "values": [{"_type": "Constant", "_fields": {"kind": null, "value": "PUT"}}, {"_type": "Name", "_fields": {"id": "path", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "sent", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Dict", "_fields": {"keys": [{"_type": "Constant", "_fields": {"kind": null, "value": "uniqueWriterIdentity"}}], "values": [{"_type": "Constant", "_fields": {"kind": null, "value": true}}]}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "expected", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_called_with", "value": {"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Name", "_fields": {"id": "expected", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "name": "test_sink_update_hit", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def test_sink_update_hit(self): sent = { 'name': self.SINK_NAME, 'filter': self.FILTER, 'destination': self.DESTINATION_URI, } after_update = sent.copy() after_update['writerIdentity'] = self.WRITER_IDENTITY conn = _Connection(after_update) client = _Client(conn) api = self._make_one(client) returned = api.sink_update( self.PROJECT, self.SINK_NAME, self.FILTER, self.DESTINATION_URI, unique_writer_identity=True) self.assertEqual(returned, after_update) path = '/projects/%s/sinks/%s' % (self.PROJECT, self.SINK_NAME) expected = { 'method': 'PUT', 'path': path, 'data': sent, 'query_params': {'uniqueWriterIdentity': True}, } self.assertEqual(conn._called_with, expected)
14,440
[ 0.029968611896038055, -0.030201107263565063, -0.01320571918040514, -0.013961328193545341, 0.004484248347580433, -0.018088115379214287, -0.005969310645014048, -0.021145425736904144, 0.029596619307994843, 0.0007912097498774529, 0.013659084215760231, -0.02187778428196907, -0.007753709796816111,...
8
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Dict", "_fields": {"keys": [{"_type": "Constant", "_fields": {"kind": null, "value": "name"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "filter"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "description"}}], "values": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "METRIC_NAME", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "FILTER", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "DESCRIPTION", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "SENT", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Dict", "_fields": {"keys": [], "values": []}}], "func": {"_type": "Name", "_fields": {"id": "_Connection", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "_Client", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "client", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "client", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_make_one", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "api", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "PROJECT", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "METRIC_NAME", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "FILTER", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "DESCRIPTION", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "metric_create", "value": {"_type": "Name", "_fields": {"id": "api", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "method"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_called_with", "value": {"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": "POST"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Mod", "_fields": {}}, "left": {"_type": "Constant", "_fields": {"kind": null, "value": "/projects/%s/metrics"}}, "right": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "PROJECT", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}}}, "targets": [{"_type": "Name", "_fields": {"id": "path", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "path"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_called_with", "value": {"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Name", "_fields": {"id": "path", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "data"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_called_with", "value": {"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Name", "_fields": {"id": "SENT", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "name": "test_metric_create_ok", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def test_metric_create_ok(self): SENT = { 'name': self.METRIC_NAME, 'filter': self.FILTER, 'description': self.DESCRIPTION, } conn = _Connection({}) client = _Client(conn) api = self._make_one(client) api.metric_create( self.PROJECT, self.METRIC_NAME, self.FILTER, self.DESCRIPTION) self.assertEqual(conn._called_with['method'], 'POST') path = '/projects/%s/metrics' % (self.PROJECT,) self.assertEqual(conn._called_with['path'], path) self.assertEqual(conn._called_with['data'], SENT)
14,441
[ -0.01571342535316944, -0.03863077983260155, 0.013451997190713882, -0.026157956570386887, 0.008661034516990185, 0.005254322197288275, -0.04581139609217644, 0.005767223425209522, 0.03643929213285446, 0.0136851342394948, 0.00580802233889699, -0.02585487999022007, -0.0077401441521942616, -0.00...
8
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Dict", "_fields": {"keys": [{"_type": "Constant", "_fields": {"kind": null, "value": "name"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "filter"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "description"}}], "values": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "METRIC_NAME", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "FILTER", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "DESCRIPTION", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "RESPONSE", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "RESPONSE", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "_Connection", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "_Client", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "client", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "client", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_make_one", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "api", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "PROJECT", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "METRIC_NAME", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "metric_get", "value": {"_type": "Name", "_fields": {"id": "api", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "response", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "response", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "RESPONSE", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "method"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_called_with", "value": {"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": "GET"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Mod", "_fields": {}}, "left": {"_type": "Constant", "_fields": {"kind": null, "value": "/projects/%s/metrics/%s"}}, "right": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "PROJECT", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "METRIC_NAME", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}}}, "targets": [{"_type": "Name", "_fields": {"id": "path", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "path"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_called_with", "value": {"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Name", "_fields": {"id": "path", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "name": "test_metric_get_hit", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def test_metric_get_hit(self): RESPONSE = { 'name': self.METRIC_NAME, 'filter': self.FILTER, 'description': self.DESCRIPTION, } conn = _Connection(RESPONSE) client = _Client(conn) api = self._make_one(client) response = api.metric_get(self.PROJECT, self.METRIC_NAME) self.assertEqual(response, RESPONSE) self.assertEqual(conn._called_with['method'], 'GET') path = '/projects/%s/metrics/%s' % (self.PROJECT, self.METRIC_NAME) self.assertEqual(conn._called_with['path'], path)
14,442
[ 0.020825300365686417, -0.04344227537512779, -0.008039264008402824, -0.017253587022423744, 0.000195418979274109, 0.03371604532003403, -0.008347571827471256, -0.0014361023204401135, 0.0207205917686224, -0.001858570845797658, 0.00984257273375988, -0.015299033373594284, -0.03857916221022606, 0...
8
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Dict", "_fields": {"keys": [{"_type": "Constant", "_fields": {"kind": null, "value": "name"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "filter"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "description"}}], "values": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "METRIC_NAME", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "FILTER", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "DESCRIPTION", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "SENT", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Dict", "_fields": {"keys": [], "values": []}}], "func": {"_type": "Name", "_fields": {"id": "_Connection", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "_Client", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "client", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "client", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_make_one", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "api", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "PROJECT", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "METRIC_NAME", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "FILTER", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "DESCRIPTION", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "metric_update", "value": {"_type": "Name", "_fields": {"id": "api", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "method"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_called_with", "value": {"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": "PUT"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Mod", "_fields": {}}, "left": {"_type": "Constant", "_fields": {"kind": null, "value": "/projects/%s/metrics/%s"}}, "right": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "PROJECT", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "METRIC_NAME", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}}}, "targets": [{"_type": "Name", "_fields": {"id": "path", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "path"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_called_with", "value": {"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Name", "_fields": {"id": "path", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "data"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_called_with", "value": {"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Name", "_fields": {"id": "SENT", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "name": "test_metric_update_hit", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def test_metric_update_hit(self): SENT = { 'name': self.METRIC_NAME, 'filter': self.FILTER, 'description': self.DESCRIPTION, } conn = _Connection({}) client = _Client(conn) api = self._make_one(client) api.metric_update( self.PROJECT, self.METRIC_NAME, self.FILTER, self.DESCRIPTION) self.assertEqual(conn._called_with['method'], 'PUT') path = '/projects/%s/metrics/%s' % (self.PROJECT, self.METRIC_NAME) self.assertEqual(conn._called_with['path'], path) self.assertEqual(conn._called_with['data'], SENT)
14,443
[ 0.030488893389701843, -0.018244976177811623, 0.02705971710383892, -0.039171744138002396, 0.004627189598977566, 0.03710544481873512, -0.03824850171804428, 0.010155636817216873, 0.042578935623168945, -0.004269983619451523, 0.028246739879250526, -0.04712919145822525, -0.027455391362309456, 0....
8
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Dict", "_fields": {"keys": [], "values": []}}], "func": {"_type": "Name", "_fields": {"id": "_Connection", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "_Client", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "client", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "client", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_make_one", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "api", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "PROJECT", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "METRIC_NAME", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "metric_delete", "value": {"_type": "Name", "_fields": {"id": "api", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "method"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_called_with", "value": {"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": "DELETE"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Mod", "_fields": {}}, "left": {"_type": "Constant", "_fields": {"kind": null, "value": "/projects/%s/metrics/%s"}}, "right": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "PROJECT", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "METRIC_NAME", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}}}, "targets": [{"_type": "Name", "_fields": {"id": "path", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "path"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_called_with", "value": {"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Name", "_fields": {"id": "path", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "name": "test_metric_delete_hit", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def test_metric_delete_hit(self): conn = _Connection({}) client = _Client(conn) api = self._make_one(client) api.metric_delete(self.PROJECT, self.METRIC_NAME) self.assertEqual(conn._called_with['method'], 'DELETE') path = '/projects/%s/metrics/%s' % (self.PROJECT, self.METRIC_NAME) self.assertEqual(conn._called_with['path'], path)
14,444
[ 0.0017681671306490898, 0.03608119860291481, 0.04356575384736061, -0.060441307723522186, 0.023854074999690056, 0.03255074843764305, -0.00953221507370472, -0.0002712194691412151, -0.006943218410015106, 0.03109149821102619, 0.01828773133456707, 0.012027067132294178, 0.009720506146550179, -0.0...
14
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "conn", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "tmp", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "module_name", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "module_args", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "inject", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "complex_args", "annotation": null, "type_comment": null}}], "kwarg": {"_type": "arg", "_fields": {"arg": "kwargs", "annotation": null, "type_comment": null}}, "vararg": null, "defaults": [{"_type": "Constant", "_fields": {"kind": null, "value": null}}], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "If", "_fields": {"body": [{"_type": "Return", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "ReturnData", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "conn", "value": {"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "comm_ok", "value": {"_type": "Constant", "_fields": {"kind": null, "value": true}}}}, {"_type": "keyword", "_fields": {"arg": "result", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "dict", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "skipped", "value": {"_type": "Constant", "_fields": {"kind": null, "value": true}}}}, {"_type": "keyword", "_fields": {"arg": "msg", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "check mode not supported for this module"}}}}]}}}}]}}}}], "test": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "inject", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "noop_on_check", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "runner", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}, "orelse": []}}, {"_type": "Assign", "_fields": {"value": {"_type": "Dict", "_fields": {"keys": [], "values": []}}, "targets": [{"_type": "Name", "_fields": {"id": "args", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "If", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "complex_args", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "update", "value": {"_type": "Name", "_fields": {"id": "args", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "test": {"_type": "Name", "_fields": {"id": "complex_args", "ctx": {"_type": "Load", "_fields": {}}}}, "orelse": []}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "module_args", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "parse_kv", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "update", "value": {"_type": "Name", "_fields": {"id": "args", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "If", "_fields": {"body": [{"_type": "Raise", "_fields": {"exc": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "'name' is a required argument."}}], "func": {"_type": "Name", "_fields": {"id": "ae", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "cause": null}}], "test": {"_type": "BoolOp", "_fields": {"op": {"_type": "And", "_fields": {}}, "values": [{"_type": "UnaryOp", "_fields": {"op": {"_type": "Not", "_fields": {}}, "operand": {"_type": "Compare", "_fields": {"ops": [{"_type": "In", "_fields": {}}], "left": {"_type": "Constant", "_fields": {"kind": null, "value": "hostname"}}, "comparators": [{"_type": "Name", "_fields": {"id": "args", "ctx": {"_type": "Load", "_fields": {}}}}]}}}}, {"_type": "UnaryOp", "_fields": {"op": {"_type": "Not", "_fields": {}}, "operand": {"_type": "Compare", "_fields": {"ops": [{"_type": "In", "_fields": {}}], "left": {"_type": "Constant", "_fields": {"kind": null, "value": "name"}}, "comparators": [{"_type": "Name", "_fields": {"id": "args", "ctx": {"_type": "Load", "_fields": {}}}}]}}}}]}}, "orelse": []}}, {"_type": "Assign", "_fields": {"value": {"_type": "Dict", "_fields": {"keys": [], "values": []}}, "targets": [{"_type": "Name", "_fields": {"id": "result", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "name"}}, {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "hostname"}}, {"_type": "Constant", "_fields": {"kind": null, "value": null}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get", "value": {"_type": "Name", "_fields": {"id": "args", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get", "value": {"_type": "Name", "_fields": {"id": "args", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "new_name", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Mod", "_fields": {}}, "left": {"_type": "Constant", "_fields": {"kind": null, "value": "creating host via 'add_host': hostname=%s"}}, "right": {"_type": "Name", "_fields": {"id": "new_name", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Name", "_fields": {"id": "vv", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": ":"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "split", "value": {"_type": "Name", "_fields": {"id": "new_name", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "new_name", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "new_port", "ctx": {"_type": "Store", "_fields": {}}}}]}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Name", "_fields": {"id": "new_port", "ctx": {"_type": "Load", "_fields": {}}}}, "targets": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "ansible_ssh_port"}}, "value": {"_type": "Name", "_fields": {"id": "args", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "In", "_fields": {}}], "left": {"_type": "Constant", "_fields": {"kind": null, "value": ":"}}, "comparators": [{"_type": "Name", "_fields": {"id": "new_name", "ctx": {"_type": "Load", "_fields": {}}}}]}}, "orelse": []}}, {"_type": "Assign", "_fields": {"value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "inventory", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "runner", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "inventory", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "all"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_group", "value": {"_type": "Name", "_fields": {"id": "inventory", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "allgroup", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Name", "_fields": {"id": "new_name", "ctx": {"_type": "Load", "_fields": {}}}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_hosts_cache", "value": {"_type": "Name", "_fields": {"id": "inventory", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "new_host", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "In", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "new_name", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_hosts_cache", "value": {"_type": "Name", "_fields": {"id": "inventory", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "orelse": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "new_name", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "Host", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "new_host", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Name", "_fields": {"id": "new_host", "ctx": {"_type": "Load", "_fields": {}}}}, "targets": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "slice": {"_type": "Name", "_fields": {"id": "new_name", "ctx": {"_type": "Load", "_fields": {}}}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_hosts_cache", "value": {"_type": "Name", "_fields": {"id": "inventory", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "new_host", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "add_host", "value": {"_type": "Name", "_fields": {"id": "allgroup", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}]}}, {"_type": "For", "_fields": {"body": [{"_type": "If", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "k", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Name", "_fields": {"id": "k", "ctx": {"_type": "Load", "_fields": {}}}}, "value": {"_type": "Name", "_fields": {"id": "args", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "set_variable", "value": {"_type": "Name", "_fields": {"id": "new_host", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "test": {"_type": "UnaryOp", "_fields": {"op": {"_type": "Not", "_fields": {}}, "operand": {"_type": "Compare", "_fields": {"ops": [{"_type": "In", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "k", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": "name"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "hostname"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "groupname"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "groups"}}]}}]}}}}, "orelse": []}}], "iter": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "keys", "value": {"_type": "Name", "_fields": {"id": "args", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "orelse": [], "target": {"_type": "Name", "_fields": {"id": "k", "ctx": {"_type": "Store", "_fields": {}}}}, "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "groupname"}}, {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "groups"}}, {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "group"}}, {"_type": "Constant", "_fields": {"kind": null, "value": ""}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get", "value": {"_type": "Name", "_fields": {"id": "args", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get", "value": {"_type": "Name", "_fields": {"id": "args", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get", "value": {"_type": "Name", "_fields": {"id": "args", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "groupnames", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "If", "_fields": {"body": [{"_type": "For", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "strip", "value": {"_type": "Name", "_fields": {"id": "group_name", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "group_name", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "group_name", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "Group", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "new_group", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "new_group", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "add_group", "value": {"_type": "Name", "_fields": {"id": "inventory", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "test": {"_type": "UnaryOp", "_fields": {"op": {"_type": "Not", "_fields": {}}, "operand": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "group_name", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_group", "value": {"_type": "Name", "_fields": {"id": "inventory", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "orelse": []}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "group_name", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_group", "value": {"_type": "Name", "_fields": {"id": "inventory", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "grp", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "new_host", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "add_host", "value": {"_type": "Name", "_fields": {"id": "grp", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "If", "_fields": {"body": [{"_type": "If", "_fields": {"body": [{"_type": "If", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "name", "value": {"_type": "Name", "_fields": {"id": "new_host", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "append", "value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Name", "_fields": {"id": "group_name", "ctx": {"_type": "Load", "_fields": {}}}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_groups_list", "value": {"_type": "Name", "_fields": {"id": "inventory", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": []}}}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "NotIn", "_fields": {}}], "left": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "name", "value": {"_type": "Name", "_fields": {"id": "new_host", "ctx": {"_type": "Load", "_fields": {}}}}}}, "comparators": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Name", "_fields": {"id": "group_name", "ctx": {"_type": "Load", "_fields": {}}}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_groups_list", "value": {"_type": "Name", "_fields": {"id": "inventory", "ctx": {"_type": "Load", "_fields": {}}}}}}}}]}}, "orelse": []}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "In", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "group_name", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_groups_list", "value": {"_type": "Name", "_fields": {"id": "inventory", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "orelse": []}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "IsNot", "_fields": {}}], "left": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_groups_list", "value": {"_type": "Name", "_fields": {"id": "inventory", "ctx": {"_type": "Load", "_fields": {}}}}}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": null}}]}}, "orelse": []}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Mod", "_fields": {}}, "left": {"_type": "Constant", "_fields": {"kind": null, "value": "added host to group via add_host module: %s"}}, "right": {"_type": "Name", "_fields": {"id": "group_name", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Name", "_fields": {"id": "vv", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}], "iter": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": ","}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "split", "value": {"_type": "Name", "_fields": {"id": "groupnames", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "orelse": [], "target": {"_type": "Name", "_fields": {"id": "group_name", "ctx": {"_type": "Store", "_fields": {}}}}, "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": ","}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "split", "value": {"_type": "Name", "_fields": {"id": "groupnames", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "new_groups"}}, "value": {"_type": "Name", "_fields": {"id": "result", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "NotEq", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "groupnames", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": ""}}]}}, "orelse": []}}, {"_type": "Assign", "_fields": {"value": {"_type": "Name", "_fields": {"id": "new_name", "ctx": {"_type": "Load", "_fields": {}}}}, "targets": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "new_host"}}, "value": {"_type": "Name", "_fields": {"id": "result", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "clear_pattern_cache", "value": {"_type": "Name", "_fields": {"id": "inventory", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Return", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "ReturnData", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "conn", "value": {"_type": "Name", "_fields": {"id": "conn", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "comm_ok", "value": {"_type": "Constant", "_fields": {"kind": null, "value": true}}}}, {"_type": "keyword", "_fields": {"arg": "result", "value": {"_type": "Name", "_fields": {"id": "result", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}}}], "name": "run", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def run(self, conn, tmp, module_name, module_args, inject, complex_args=None, **kwargs): if self.runner.noop_on_check(inject): return ReturnData(conn=conn, comm_ok=True, result=dict(skipped=True, msg='check mode not supported for this module')) args = {} if complex_args: args.update(complex_args) args.update(parse_kv(module_args)) if not 'hostname' in args and not 'name' in args: raise ae("'name' is a required argument.") result = {} # Parse out any hostname:port patterns new_name = args.get('name', args.get('hostname', None)) vv("creating host via 'add_host': hostname=%s" % new_name) if ":" in new_name: new_name, new_port = new_name.split(":") args['ansible_ssh_port'] = new_port # redefine inventory and get group "all" inventory = self.runner.inventory allgroup = inventory.get_group('all') # check if host in cache, add if not if new_name in inventory._hosts_cache: new_host = inventory._hosts_cache[new_name] else: new_host = Host(new_name) # only groups can be added directly to inventory inventory._hosts_cache[new_name] = new_host allgroup.add_host(new_host) # Add any variables to the new_host for k in args.keys(): if not k in [ 'name', 'hostname', 'groupname', 'groups' ]: new_host.set_variable(k, args[k]) groupnames = args.get('groupname', args.get('groups', args.get('group', ''))) # add it to the group if that was specified if groupnames != '': for group_name in groupnames.split(","): group_name = group_name.strip() if not inventory.get_group(group_name): new_group = Group(group_name) inventory.add_group(new_group) grp = inventory.get_group(group_name) grp.add_host(new_host) # add this host to the group cache if inventory._groups_list is not None: if group_name in inventory._groups_list: if new_host.name not in inventory._groups_list[group_name]: inventory._groups_list[group_name].append(new_host.name) vv("added host to group via add_host module: %s" % group_name) result['new_groups'] = groupnames.split(",") result['new_host'] = new_name # clear pattern caching completely since it's unpredictable what # patterns may have referenced the group inventory.clear_pattern_cache() return ReturnData(conn=conn, comm_ok=True, result=result)
14,445
[ 0.01909196563065052, -0.015601223334670067, 0.06411875784397125, -0.01645815744996071, 0.03687332943081856, 0.02070501632988453, -0.011612704023718834, -0.028732463717460632, -0.05786819010972977, 0.002994540147483349, 0.05088670551776886, -0.10746949911117554, 0.00460916617885232, -0.0325...
9
{"_type": "Module", "_fields": {"body": [{"_type": "ClassDef", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "ListComp", "_fields": {"elt": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "n", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "str", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "generators": [{"_type": "comprehension", "_fields": {"ifs": [], "iter": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 2}}, {"_type": "Constant", "_fields": {"kind": null, "value": 11}}], "func": {"_type": "Name", "_fields": {"id": "range", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "target": {"_type": "Name", "_fields": {"id": "n", "ctx": {"_type": "Store", "_fields": {}}}}, "is_async": 0}}]}}, "right": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "JQKA"}}], "func": {"_type": "Name", "_fields": {"id": "list", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "ranks", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "split", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "spades diamonds clubs hearts"}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "suits", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "ListComp", "_fields": {"elt": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "rank", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "suit", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "Card", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "generators": [{"_type": "comprehension", "_fields": {"ifs": [], "iter": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "suits", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "target": {"_type": "Name", "_fields": {"id": "suit", "ctx": {"_type": "Store", "_fields": {}}}}, "is_async": 0}}, {"_type": "comprehension", "_fields": {"ifs": [], "iter": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "ranks", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "target": {"_type": "Name", "_fields": {"id": "rank", "ctx": {"_type": "Store", "_fields": {}}}}, "is_async": 0}}]}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "_cards", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}], "name": "__init__", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Return", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_cards", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Name", "_fields": {"id": "len", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}], "name": "__len__", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "position", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Return", "_fields": {"value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Name", "_fields": {"id": "position", "ctx": {"_type": "Load", "_fields": {}}}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_cards", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}], "name": "__getitem__", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "position", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "card", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Name", "_fields": {"id": "card", "ctx": {"_type": "Load", "_fields": {}}}}, "targets": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "slice": {"_type": "Name", "_fields": {"id": "position", "ctx": {"_type": "Load", "_fields": {}}}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_cards", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "type_comment": null}}], "name": "__setitem__", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "position", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Delete", "_fields": {"targets": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Del", "_fields": {}}, "slice": {"_type": "Name", "_fields": {"id": "position", "ctx": {"_type": "Load", "_fields": {}}}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_cards", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}]}}], "name": "__delitem__", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "position", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "card", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "position", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "card", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "insert", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_cards", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}], "name": "insert", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "name": "FrenchDeck", "bases": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "MutableSequence", "value": {"_type": "Name", "_fields": {"id": "abc", "ctx": {"_type": "Load", "_fields": {}}}}}}], "keywords": [], "type_params": [], "decorator_list": []}}], "type_ignores": []}}
class FrenchDeck(abc.MutableSequence): ranks = [str(n) for n in range(2, 11)] + list('JQKA') suits = 'spades diamonds clubs hearts'.split() def __init__(self): self._cards = [Card(rank, suit) for suit in self.suits for rank in self.ranks] def __len__(self): return len(self._cards) def __getitem__(self, position): return self._cards[position] def __setitem__(self, position, card): self._cards[position] = card def __delitem__(self, position): del self._cards[position] def insert(self, position, card): self._cards.insert(position, card)
14,446
[ 0.02736978977918625, 0.0052377511747181416, 0.07150038331747055, -0.02102064900100231, -0.025953710079193115, 0.02681264467537403, 0.0033835002686828375, 0.01756170205771923, -0.0012064238544553518, 0.01508936658501625, 0.000883598520886153, -0.07985757291316986, 0.02864658273756504, -0.01...
10
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "abbr", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "_speech_report_dict", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "defaultdict", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "sessions", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "For", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "session"}}, "value": {"_type": "Name", "_fields": {"id": "speech", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "session", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Name", "_fields": {"id": "session", "ctx": {"_type": "Load", "_fields": {}}}}, "value": {"_type": "Name", "_fields": {"id": "sessions", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "obj", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "If", "_fields": {"body": [{"_type": "AugAssign", "_fields": {"op": {"_type": "Add", "_fields": {}}, "value": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}, "target": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "_speakers_with_id_count"}}, "value": {"_type": "Name", "_fields": {"id": "obj", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "test": {"_type": "BoolOp", "_fields": {"op": {"_type": "And", "_fields": {}}, "values": [{"_type": "Compare", "_fields": {"ops": [{"_type": "In", "_fields": {}}], "left": {"_type": "Constant", "_fields": {"kind": null, "value": "speaker_id"}}, "comparators": [{"_type": "Name", "_fields": {"id": "speech", "ctx": {"_type": "Load", "_fields": {}}}}]}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "speaker_id"}}, "value": {"_type": "Name", "_fields": {"id": "speech", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "orelse": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "speaker"}}, "value": {"_type": "Name", "_fields": {"id": "speech", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "add", "value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "unmatched_speakers"}}, "value": {"_type": "Name", "_fields": {"id": "obj", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}]}}], "iter": {"_type": "Call", "_fields": {"args": [{"_type": "Dict", "_fields": {"keys": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "LEVEL_FIELD", "value": {"_type": "Name", "_fields": {"id": "settings", "ctx": {"_type": "Load", "_fields": {}}}}}}], "values": [{"_type": "Name", "_fields": {"id": "abbr", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "find", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "speeches", "value": {"_type": "Name", "_fields": {"id": "db", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}, "orelse": [], "target": {"_type": "Name", "_fields": {"id": "speech", "ctx": {"_type": "Store", "_fields": {}}}}, "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": "unmatched_speakers"}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "sets", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "For", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Name", "_fields": {"id": "session", "ctx": {"_type": "Load", "_fields": {}}}}, "value": {"_type": "Name", "_fields": {"id": "sessions", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "sobj", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "For", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Name", "_fields": {"id": "key", "ctx": {"_type": "Load", "_fields": {}}}}, "value": {"_type": "Name", "_fields": {"id": "sobj", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Name", "_fields": {"id": "list", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "slice": {"_type": "Name", "_fields": {"id": "key", "ctx": {"_type": "Load", "_fields": {}}}}, "value": {"_type": "Name", "_fields": {"id": "sobj", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}], "iter": {"_type": "Name", "_fields": {"id": "sets", "ctx": {"_type": "Load", "_fields": {}}}}, "orelse": [], "target": {"_type": "Name", "_fields": {"id": "key", "ctx": {"_type": "Store", "_fields": {}}}}, "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Name", "_fields": {"id": "sobj", "ctx": {"_type": "Load", "_fields": {}}}}, "targets": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "slice": {"_type": "Name", "_fields": {"id": "session", "ctx": {"_type": "Load", "_fields": {}}}}, "value": {"_type": "Name", "_fields": {"id": "sessions", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}], "iter": {"_type": "Name", "_fields": {"id": "sessions", "ctx": {"_type": "Load", "_fields": {}}}}, "orelse": [], "target": {"_type": "Name", "_fields": {"id": "session", "ctx": {"_type": "Store", "_fields": {}}}}, "type_comment": null}}, {"_type": "Return", "_fields": {"value": {"_type": "Name", "_fields": {"id": "sessions", "ctx": {"_type": "Load", "_fields": {}}}}}}], "name": "scan_speeches", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def scan_speeches(abbr): sessions = defaultdict(_speech_report_dict) for speech in db.speeches.find({settings.LEVEL_FIELD: abbr}): session = speech['session'] obj = sessions[session] if "speaker_id" in speech and speech['speaker_id']: obj['_speakers_with_id_count'] += 1 else: obj['unmatched_speakers'].add(speech['speaker']) sets = ['unmatched_speakers'] for session in sessions: sobj = sessions[session] for key in sets: sobj[key] = list(sobj[key]) sessions[session] = sobj return sessions
14,447
[ 0.03030761331319809, 0.03504948318004608, 0.046530865132808685, -0.021025655791163445, 0.0021376251243054867, -0.013277237303555012, 0.009206291288137436, 0.021166902035474777, -0.015123539604246616, 0.0264737606048584, 0.02958120033144951, 0.03849995136260986, 0.03950886055827141, -0.0092...
9
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "cmd", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "basename", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "filename", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "If", "_fields": {"body": [{"_type": "Return", "_fields": {"value": null}}], "test": {"_type": "BoolOp", "_fields": {"op": {"_type": "Or", "_fields": {}}, "values": [{"_type": "UnaryOp", "_fields": {"op": {"_type": "Not", "_fields": {}}, "operand": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distribution", "value": {"_type": "Name", "_fields": {"id": "cmd", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": "pbr"}}], "func": {"_type": "Name", "_fields": {"id": "hasattr", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "UnaryOp", "_fields": {"op": {"_type": "Not", "_fields": {}}, "operand": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "pbr", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distribution", "value": {"_type": "Name", "_fields": {"id": "cmd", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}]}}, "orelse": []}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_run_git_functions", "value": {"_type": "Name", "_fields": {"id": "git", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "git_dir", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "If", "_fields": {"body": [{"_type": "Return", "_fields": {"value": null}}], "test": {"_type": "UnaryOp", "_fields": {"op": {"_type": "Not", "_fields": {}}, "operand": {"_type": "Name", "_fields": {"id": "git_dir", "ctx": {"_type": "Load", "_fields": {}}}}}}, "orelse": []}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "dict", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "values", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "git_dir", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_git_short_sha", "value": {"_type": "Name", "_fields": {"id": "git", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "git_version", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "git_dir", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_is_release", "value": {"_type": "Name", "_fields": {"id": "git", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "is_release", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Name", "_fields": {"id": "git_version", "ctx": {"_type": "Load", "_fields": {}}}}, "targets": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "git_version"}}, "value": {"_type": "Name", "_fields": {"id": "values", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Name", "_fields": {"id": "is_release", "ctx": {"_type": "Load", "_fields": {}}}}, "targets": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "is_release"}}, "value": {"_type": "Name", "_fields": {"id": "values", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "pbr"}}, {"_type": "Name", "_fields": {"id": "filename", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "values", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "dumps", "value": {"_type": "Name", "_fields": {"id": "json", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "write_file", "value": {"_type": "Name", "_fields": {"id": "cmd", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "IsNot", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "git_version", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": null}}]}}, "orelse": []}}], "name": "write_pbr_json", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def write_pbr_json(cmd, basename, filename): if not hasattr(cmd.distribution, 'pbr') or not cmd.distribution.pbr: return git_dir = git._run_git_functions() if not git_dir: return values = dict() git_version = git.get_git_short_sha(git_dir) is_release = git.get_is_release(git_dir) if git_version is not None: values['git_version'] = git_version values['is_release'] = is_release cmd.write_file('pbr', filename, json.dumps(values))
14,448
[ 0.031626056879758835, -0.0044372184202075005, -0.007471492979675531, 0.004355652257800102, 0.055813249200582504, -0.018531912937760353, 0.025296496227383614, 0.06781984120607376, 0.01777062565088272, -0.003855377435684204, 0.0029146436136215925, -0.015356256626546383, 0.05668329447507858, ...
9
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "userid", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "password", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "If", "_fields": {"body": [{"_type": "Return", "_fields": {"value": null}}], "test": {"_type": "Name", "_fields": {"id": "password", "ctx": {"_type": "Load", "_fields": {}}}}, "orelse": []}}, {"_type": "Try", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_from_cache", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "objects", "value": {"_type": "Name", "_fields": {"id": "ApiKey", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "key", "value": {"_type": "Name", "_fields": {"id": "userid", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "key", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}], "orelse": [], "handlers": [{"_type": "ExceptHandler", "_fields": {"body": [{"_type": "Return", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": null}}}}], "name": null, "type": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "DoesNotExist", "value": {"_type": "Name", "_fields": {"id": "ApiKey", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "finalbody": []}}, {"_type": "If", "_fields": {"body": [{"_type": "Raise", "_fields": {"exc": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "Key is disabled"}}], "func": {"_type": "Name", "_fields": {"id": "AuthenticationFailed", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "cause": null}}], "test": {"_type": "UnaryOp", "_fields": {"op": {"_type": "Not", "_fields": {}}, "operand": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "is_active", "value": {"_type": "Name", "_fields": {"id": "key", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "orelse": []}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Dict", "_fields": {"keys": [{"_type": "Constant", "_fields": {"kind": null, "value": "api_key"}}], "values": [{"_type": "Name", "_fields": {"id": "userid", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "tags_context", "value": {"_type": "Name", "_fields": {"id": "raven", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Return", "_fields": {"value": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "AnonymousUser", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, {"_type": "Name", "_fields": {"id": "key", "ctx": {"_type": "Load", "_fields": {}}}}]}}}}], "name": "authenticate_credentials", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def authenticate_credentials(self, userid, password): if password: return try: key = ApiKey.objects.get_from_cache(key=userid) except ApiKey.DoesNotExist: return None if not key.is_active: raise AuthenticationFailed('Key is disabled') raven.tags_context({ 'api_key': userid, }) return (AnonymousUser(), key)
14,449
[ 0.04064595326781273, 0.021910207346081734, -0.007346300408244133, -0.0018553431145846844, 0.024258878082036972, -0.012665665708482265, -0.007233693264424801, 0.05435189977288246, -0.0070192026905715466, -0.004826036747545004, -0.015121581964194775, -0.024838002398610115, 0.013545076362788677...
10
{"_type": "Module", "_fields": {"body": [{"_type": "ClassDef", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "userid", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "password", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "If", "_fields": {"body": [{"_type": "Return", "_fields": {"value": null}}], "test": {"_type": "Name", "_fields": {"id": "password", "ctx": {"_type": "Load", "_fields": {}}}}, "orelse": []}}, {"_type": "Try", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_from_cache", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "objects", "value": {"_type": "Name", "_fields": {"id": "ApiKey", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "key", "value": {"_type": "Name", "_fields": {"id": "userid", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "key", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}], "orelse": [], "handlers": [{"_type": "ExceptHandler", "_fields": {"body": [{"_type": "Return", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": null}}}}], "name": null, "type": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "DoesNotExist", "value": {"_type": "Name", "_fields": {"id": "ApiKey", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "finalbody": []}}, {"_type": "If", "_fields": {"body": [{"_type": "Raise", "_fields": {"exc": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "Key is disabled"}}], "func": {"_type": "Name", "_fields": {"id": "AuthenticationFailed", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "cause": null}}], "test": {"_type": "UnaryOp", "_fields": {"op": {"_type": "Not", "_fields": {}}, "operand": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "is_active", "value": {"_type": "Name", "_fields": {"id": "key", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "orelse": []}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Dict", "_fields": {"keys": [{"_type": "Constant", "_fields": {"kind": null, "value": "api_key"}}], "values": [{"_type": "Name", "_fields": {"id": "userid", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "tags_context", "value": {"_type": "Name", "_fields": {"id": "raven", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Return", "_fields": {"value": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "AnonymousUser", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, {"_type": "Name", "_fields": {"id": "key", "ctx": {"_type": "Load", "_fields": {}}}}]}}}}], "name": "authenticate_credentials", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "name": "ApiKeyAuthentication", "bases": [{"_type": "Name", "_fields": {"id": "QuietBasicAuthentication", "ctx": {"_type": "Load", "_fields": {}}}}], "keywords": [], "type_params": [], "decorator_list": []}}], "type_ignores": []}}
class ApiKeyAuthentication(QuietBasicAuthentication): def authenticate_credentials(self, userid, password): if password: return try: key = ApiKey.objects.get_from_cache(key=userid) except ApiKey.DoesNotExist: return None if not key.is_active: raise AuthenticationFailed('Key is disabled') raven.tags_context({ 'api_key': userid, }) return (AnonymousUser(), key)
14,450
[ 0.025910217314958572, 0.012449805624783039, 0.013127126730978489, 0.0029646235052496195, 0.029716117307543755, 0.017406076192855835, -0.010288828983902931, 0.03373703733086586, -0.013116375543177128, -0.0043595824390649796, -0.003499492071568966, -0.019857332110404968, -0.0039080348797142506...
10
{"_type": "Module", "_fields": {"body": [{"_type": "ClassDef", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "userid", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "password", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Try", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_from_cache", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "objects", "value": {"_type": "Name", "_fields": {"id": "ProjectKey", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "public_key", "value": {"_type": "Name", "_fields": {"id": "userid", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "pk", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}], "orelse": [], "handlers": [{"_type": "ExceptHandler", "_fields": {"body": [{"_type": "Return", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": null}}}}], "name": null, "type": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "DoesNotExist", "value": {"_type": "Name", "_fields": {"id": "ProjectKey", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "finalbody": []}}, {"_type": "If", "_fields": {"body": [{"_type": "Return", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": null}}}}], "test": {"_type": "UnaryOp", "_fields": {"op": {"_type": "Not", "_fields": {}}, "operand": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "secret_key", "value": {"_type": "Name", "_fields": {"id": "pk", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Name", "_fields": {"id": "password", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "constant_time_compare", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, "orelse": []}}, {"_type": "If", "_fields": {"body": [{"_type": "Raise", "_fields": {"exc": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "Key is disabled"}}], "func": {"_type": "Name", "_fields": {"id": "AuthenticationFailed", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "cause": null}}], "test": {"_type": "UnaryOp", "_fields": {"op": {"_type": "Not", "_fields": {}}, "operand": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "is_active", "value": {"_type": "Name", "_fields": {"id": "pk", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "orelse": []}}, {"_type": "If", "_fields": {"body": [{"_type": "Raise", "_fields": {"exc": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "Key does not allow API access"}}], "func": {"_type": "Name", "_fields": {"id": "AuthenticationFailed", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "cause": null}}], "test": {"_type": "UnaryOp", "_fields": {"op": {"_type": "Not", "_fields": {}}, "operand": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "api", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "roles", "value": {"_type": "Name", "_fields": {"id": "pk", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "orelse": []}}, {"_type": "Return", "_fields": {"value": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "AnonymousUser", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, {"_type": "Name", "_fields": {"id": "pk", "ctx": {"_type": "Load", "_fields": {}}}}]}}}}], "name": "authenticate_credentials", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "name": "ProjectKeyAuthentication", "bases": [{"_type": "Name", "_fields": {"id": "QuietBasicAuthentication", "ctx": {"_type": "Load", "_fields": {}}}}], "keywords": [], "type_params": [], "decorator_list": []}}], "type_ignores": []}}
class ProjectKeyAuthentication(QuietBasicAuthentication): def authenticate_credentials(self, userid, password): try: pk = ProjectKey.objects.get_from_cache(public_key=userid) except ProjectKey.DoesNotExist: return None if not constant_time_compare(pk.secret_key, password): return None if not pk.is_active: raise AuthenticationFailed('Key is disabled') if not pk.roles.api: raise AuthenticationFailed('Key does not allow API access') return (AnonymousUser(), pk)
14,451
[ 0.021600300446152687, -0.011019687168300152, 0.012336909770965576, 0.003341246396303177, 0.0598854161798954, 0.007699859328567982, 0.019544148817658424, 0.04930480197072029, 0.019394222646951675, -0.0006341809057630599, 0.015870919451117516, -0.00791939627379179, 0.02829350344836712, -0.04...
9
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "userid", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "password", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Try", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_from_cache", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "objects", "value": {"_type": "Name", "_fields": {"id": "ProjectKey", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "public_key", "value": {"_type": "Name", "_fields": {"id": "userid", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "pk", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}], "orelse": [], "handlers": [{"_type": "ExceptHandler", "_fields": {"body": [{"_type": "Return", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": null}}}}], "name": null, "type": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "DoesNotExist", "value": {"_type": "Name", "_fields": {"id": "ProjectKey", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "finalbody": []}}, {"_type": "If", "_fields": {"body": [{"_type": "Return", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": null}}}}], "test": {"_type": "UnaryOp", "_fields": {"op": {"_type": "Not", "_fields": {}}, "operand": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "secret_key", "value": {"_type": "Name", "_fields": {"id": "pk", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Name", "_fields": {"id": "password", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "constant_time_compare", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, "orelse": []}}, {"_type": "If", "_fields": {"body": [{"_type": "Raise", "_fields": {"exc": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "Key is disabled"}}], "func": {"_type": "Name", "_fields": {"id": "AuthenticationFailed", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "cause": null}}], "test": {"_type": "UnaryOp", "_fields": {"op": {"_type": "Not", "_fields": {}}, "operand": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "is_active", "value": {"_type": "Name", "_fields": {"id": "pk", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "orelse": []}}, {"_type": "If", "_fields": {"body": [{"_type": "Raise", "_fields": {"exc": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "Key does not allow API access"}}], "func": {"_type": "Name", "_fields": {"id": "AuthenticationFailed", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "cause": null}}], "test": {"_type": "UnaryOp", "_fields": {"op": {"_type": "Not", "_fields": {}}, "operand": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "api", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "roles", "value": {"_type": "Name", "_fields": {"id": "pk", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "orelse": []}}, {"_type": "Return", "_fields": {"value": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Name", "_fields": {"id": "AnonymousUser", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, {"_type": "Name", "_fields": {"id": "pk", "ctx": {"_type": "Load", "_fields": {}}}}]}}}}], "name": "authenticate_credentials", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def authenticate_credentials(self, userid, password): try: pk = ProjectKey.objects.get_from_cache(public_key=userid) except ProjectKey.DoesNotExist: return None if not constant_time_compare(pk.secret_key, password): return None if not pk.is_active: raise AuthenticationFailed('Key is disabled') if not pk.roles.api: raise AuthenticationFailed('Key does not allow API access') return (AnonymousUser(), pk)
14,452
[ -0.00043507482041604817, -0.0351751409471035, 0.041582606732845306, -0.0050000641494989395, -0.012894035317003727, 0.02394229918718338, -0.002564304508268833, -0.003556407056748867, 0.022439314052462578, 0.035623397678136826, 0.04121344909071922, 0.0056724525056779385, -0.04308559000492096, ...
13
{"_type": "Module", "_fields": {"body": [{"_type": "ClassDef", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": 6}}, "targets": [{"_type": "Name", "_fields": {"id": "batch_size", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}]}}, "right": {"_type": "Name", "_fields": {"id": "batch_size", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}]}}, "right": {"_type": "Name", "_fields": {"id": "batch_size", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 8.0}}]}}, "right": {"_type": "Name", "_fields": {"id": "batch_size", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, "targets": [{"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}, "targets": [{"_type": "Name", "_fields": {"id": "mu_v", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": 8.0}}, "targets": [{"_type": "Name", "_fields": {"id": "sigma_v", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 2.5}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2.5}}, {"_type": "Constant", "_fields": {"kind": null, "value": 8.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0.0}}, {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "array", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "dtype", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "float32", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "t", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "t", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "log_pdf", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "log_pdf", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_shape", "value": {"_type": "Name", "_fields": {"id": "log_pdf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 6}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEquals", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Name", "_fields": {"id": "log_pdf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "log_pdf_values", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "t", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "pdf", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "pdf", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_shape", "value": {"_type": "Name", "_fields": {"id": "pdf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 6}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEquals", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Name", "_fields": {"id": "pdf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "pdf_values", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "t", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "logpdf", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "t", "value": {"_type": "Name", "_fields": {"id": "stats", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "loc", "value": {"_type": "Name", "_fields": {"id": "mu_v", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "scale", "value": {"_type": "Name", "_fields": {"id": "sigma_v", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "expected_log_pdf", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "t", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "pdf", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "t", "value": {"_type": "Name", "_fields": {"id": "stats", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "loc", "value": {"_type": "Name", "_fields": {"id": "mu_v", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "scale", "value": {"_type": "Name", "_fields": {"id": "sigma_v", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "expected_pdf", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "expected_log_pdf", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "log_pdf_values", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "expected_pdf", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "log", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Name", "_fields": {"id": "log_pdf_values", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "expected_pdf", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "pdf_values", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "expected_log_pdf", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "exp", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Name", "_fields": {"id": "pdf_values", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "name": "testStudentPDFAndLogPDF", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": 6}}, "targets": [{"_type": "Name", "_fields": {"id": "batch_size", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 1.5}}, {"_type": "Constant", "_fields": {"kind": null, "value": 7.2}}]}}]}}, "right": {"_type": "Name", "_fields": {"id": "batch_size", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}}}]}}]}}, "right": {"_type": "Name", "_fields": {"id": "batch_size", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 10.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sqrt", "value": {"_type": "Name", "_fields": {"id": "math", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 15.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sqrt", "value": {"_type": "Name", "_fields": {"id": "math", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}]}}]}}, "right": {"_type": "Name", "_fields": {"id": "batch_size", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 1.5}}, {"_type": "Constant", "_fields": {"kind": null, "value": 7.2}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "array", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "array", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "mu_v", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 10.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sqrt", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 15.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sqrt", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "array", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "sigma_v", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "T", "value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 2.5}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2.5}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0.0}}, {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}]}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "array", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "dtype", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "float32", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}}}]}}}}, "targets": [{"_type": "Name", "_fields": {"id": "t", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "t", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "log_pdf", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "log_pdf", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Name", "_fields": {"id": "log_pdf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "log_pdf_values", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_shape", "value": {"_type": "Name", "_fields": {"id": "log_pdf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 6}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "t", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "pdf", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "pdf", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Name", "_fields": {"id": "pdf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "pdf_values", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_shape", "value": {"_type": "Name", "_fields": {"id": "pdf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 6}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "t", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "logpdf", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "t", "value": {"_type": "Name", "_fields": {"id": "stats", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "loc", "value": {"_type": "Name", "_fields": {"id": "mu_v", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "scale", "value": {"_type": "Name", "_fields": {"id": "sigma_v", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "expected_log_pdf", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "t", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "pdf", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "t", "value": {"_type": "Name", "_fields": {"id": "stats", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "loc", "value": {"_type": "Name", "_fields": {"id": "mu_v", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "scale", "value": {"_type": "Name", "_fields": {"id": "sigma_v", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "expected_pdf", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "expected_log_pdf", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "log_pdf_values", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "expected_pdf", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "log", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Name", "_fields": {"id": "log_pdf_values", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "expected_pdf", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "pdf_values", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "expected_log_pdf", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "exp", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Name", "_fields": {"id": "pdf_values", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "name": "testStudentLogPDFMultidimensional", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}]}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "array", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}, {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}]}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "array", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "mu_v", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "T", "value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}]}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "array", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "sigma_v", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Name", "_fields": {"id": "mu_v", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Name", "_fields": {"id": "sigma_v", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "entropy", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "ent", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Name", "_fields": {"id": "ent", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "ent_values", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}]}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "array", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "ones", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "sigma_v", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "Name", "_fields": {"id": "ones", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "sigma_bc", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "T", "value": {"_type": "Name", "_fields": {"id": "ones", "ctx": {"_type": "Load", "_fields": {}}}}}}, "right": {"_type": "Name", "_fields": {"id": "mu_v", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "mu_bc", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "T", "value": {"_type": "Name", "_fields": {"id": "ones", "ctx": {"_type": "Load", "_fields": {}}}}}}, "right": {"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "df_bc", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "df_bc", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "reshape", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "entropy", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "t", "value": {"_type": "Name", "_fields": {"id": "stats", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "loc", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "mu_bc", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "reshape", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "keyword", "_fields": {"arg": "scale", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "sigma_bc", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "reshape", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "expected_entropy", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "expected_entropy", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "shape", "value": {"_type": "Name", "_fields": {"id": "df_bc", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "reshape", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "expected_entropy", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "expected_entropy", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "ent_values", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "name": "testStudentEntropy", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 10.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sqrt", "value": {"_type": "Name", "_fields": {"id": "math", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}, "targets": [{"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, "targets": [{"_type": "Name", "_fields": {"id": "mu_v", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 10.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sqrt", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "sigma_v", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 200000}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "n", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "n", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sample", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "samples", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Name", "_fields": {"id": "samples", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "sample_values", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": 200000}}, "targets": [{"_type": "Name", "_fields": {"id": "n_val", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "shape", "value": {"_type": "Name", "_fields": {"id": "sample_values", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "n_val", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mean", "value": {"_type": "Name", "_fields": {"id": "sample_values", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Name", "_fields": {"id": "mu_v", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "rtol", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.01}}}}, {"_type": "keyword", "_fields": {"arg": "atol", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}}}]}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "var", "value": {"_type": "Name", "_fields": {"id": "sample_values", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "BinOp", "_fields": {"op": {"_type": "Div", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Pow", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "sigma_v", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": 2}}}}, "right": {"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Load", "_fields": {}}}}}}, "right": {"_type": "BinOp", "_fields": {"op": {"_type": "Sub", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": 2}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "rtol", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.01}}}}, {"_type": "keyword", "_fields": {"arg": "atol", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}}}]}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "mu_v", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "sigma_v", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "sample_values", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_checkKLApprox", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "name": "testStudentSample", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 10.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sqrt", "value": {"_type": "Name", "_fields": {"id": "math", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}, "targets": [{"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, "targets": [{"_type": "Name", "_fields": {"id": "mu_v", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 10.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sqrt", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "sigma_v", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 100}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "n", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 654321}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "set_random_seed", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "name", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "student_t1"}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "n", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sample", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "seed", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 123456}}}}]}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "samples1", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 654321}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "set_random_seed", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "name", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "student_t2"}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student2", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "n", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sample", "value": {"_type": "Name", "_fields": {"id": "student2", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "seed", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 123456}}}}]}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "samples2", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "samples1", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "samples2", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "name": "testStudentSampleMultipleTimes", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 0.1}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0.00001}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0.0000000001}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0.00000000000000000001}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 200000}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "n", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "n", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sample", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "samples", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Name", "_fields": {"id": "samples", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "sample_values", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": 200000}}, "targets": [{"_type": "Name", "_fields": {"id": "n_val", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "shape", "value": {"_type": "Name", "_fields": {"id": "sample_values", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "n_val", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "sample_values", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "isnan", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "logical_not", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "all", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertTrue", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "name": "testStudentSampleSmallDfNoNan", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": 7}}, "targets": [{"_type": "Name", "_fields": {"id": "batch_size", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}]}}]}}, "right": {"_type": "Name", "_fields": {"id": "batch_size", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}}}]}}]}}, "right": {"_type": "Name", "_fields": {"id": "batch_size", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 10.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sqrt", "value": {"_type": "Name", "_fields": {"id": "math", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 15.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sqrt", "value": {"_type": "Name", "_fields": {"id": "math", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}]}}]}}, "right": {"_type": "Name", "_fields": {"id": "batch_size", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "mu_v", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 10.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sqrt", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 15.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sqrt", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "sigma_v", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 200000}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "n", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "n", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sample", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "samples", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Name", "_fields": {"id": "samples", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "sample_values", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_shape", "value": {"_type": "Name", "_fields": {"id": "samples", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 200000}}, {"_type": "Name", "_fields": {"id": "batch_size", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mean", "value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}]}}, "value": {"_type": "Name", "_fields": {"id": "sample_values", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "mu_v", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "rtol", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.01}}}}, {"_type": "keyword", "_fields": {"arg": "atol", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}}}]}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "var", "value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}]}}, "value": {"_type": "Name", "_fields": {"id": "sample_values", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}, {"_type": "BinOp", "_fields": {"op": {"_type": "Div", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Pow", "_fields": {}}, "left": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "sigma_v", "ctx": {"_type": "Load", "_fields": {}}}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": 2}}}}, "right": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "right": {"_type": "BinOp", "_fields": {"op": {"_type": "Sub", "_fields": {}}, "left": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Load", "_fields": {}}}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": 2}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "rtol", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.1}}}}, {"_type": "keyword", "_fields": {"arg": "atol", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}}}]}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "mu_v", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "sigma_v", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}]}}, "value": {"_type": "Name", "_fields": {"id": "sample_values", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_checkKLApprox", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mean", "value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}]}}, "value": {"_type": "Name", "_fields": {"id": "sample_values", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}, "value": {"_type": "Name", "_fields": {"id": "mu_v", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "rtol", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.01}}}}, {"_type": "keyword", "_fields": {"arg": "atol", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}}}]}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "var", "value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}]}}, "value": {"_type": "Name", "_fields": {"id": "sample_values", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}, {"_type": "BinOp", "_fields": {"op": {"_type": "Div", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Pow", "_fields": {}}, "left": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}, "value": {"_type": "Name", "_fields": {"id": "sigma_v", "ctx": {"_type": "Load", "_fields": {}}}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": 2}}}}, "right": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}, "value": {"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "right": {"_type": "BinOp", "_fields": {"op": {"_type": "Sub", "_fields": {}}, "left": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}, "value": {"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Load", "_fields": {}}}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": 2}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "rtol", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.1}}}}, {"_type": "keyword", "_fields": {"arg": "atol", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}}}]}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "mu_v", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "sigma_v", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}]}}, "value": {"_type": "Name", "_fields": {"id": "sample_values", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_checkKLApprox", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "name": "testStudentSampleMultiDimensional", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "df", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "mu", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "sigma", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "samples", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "size", "value": {"_type": "Name", "_fields": {"id": "samples", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "n", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 137}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "seed", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "random", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "rvs", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "t", "value": {"_type": "Name", "_fields": {"id": "stats", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "loc", "value": {"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "scale", "value": {"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "size", "value": {"_type": "Name", "_fields": {"id": "n", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "sample_scipy", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.99}}, "targets": [{"_type": "Name", "_fields": {"id": "covg", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "covg", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "interval", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "t", "value": {"_type": "Name", "_fields": {"id": "stats", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "loc", "value": {"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "scale", "value": {"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "r", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": 100}}, "targets": [{"_type": "Name", "_fields": {"id": "bins", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "samples", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "histogram", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "bins", "value": {"_type": "Name", "_fields": {"id": "bins", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "range", "value": {"_type": "Name", "_fields": {"id": "r", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "hist", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "_", "ctx": {"_type": "Store", "_fields": {}}}}]}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "sample_scipy", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "histogram", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "bins", "value": {"_type": "Name", "_fields": {"id": "bins", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "range", "value": {"_type": "Name", "_fields": {"id": "r", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "hist_scipy", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "_", "ctx": {"_type": "Store", "_fields": {}}}}]}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sum", "value": {"_type": "Name", "_fields": {"id": "hist", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "n", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "BinOp", "_fields": {"op": {"_type": "Sub", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "covg", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": 0.01}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertGreater", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sum", "value": {"_type": "Name", "_fields": {"id": "hist_scipy", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "n", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "BinOp", "_fields": {"op": {"_type": "Sub", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "covg", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": 0.01}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertGreater", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "hist", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}, "targets": [{"_type": "Name", "_fields": {"id": "hist_min1", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Div", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "hist_min1", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sum", "value": {"_type": "Name", "_fields": {"id": "hist_min1", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "hist_norm", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "hist_scipy", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}, "targets": [{"_type": "Name", "_fields": {"id": "hist_scipy_min1", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Div", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "hist_scipy_min1", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sum", "value": {"_type": "Name", "_fields": {"id": "hist_scipy_min1", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "hist_scipy_norm", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Div", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "hist_scipy_norm", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "Name", "_fields": {"id": "hist_norm", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "log", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "right": {"_type": "Name", "_fields": {"id": "hist_scipy_norm", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sum", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "kl_appx", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "kl_appx", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertLess", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "name": "_checkKLApprox", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "student", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_shape", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mean", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_shape", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "variance", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_shape", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "entropy", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_shape", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "log_pdf", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_shape", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "pdf", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_shape", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 37}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sample", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 37}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "name": "_check", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}]}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}]}}], "func": {"_type": "Name", "_fields": {"id": "_check", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}]}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}]}}], "func": {"_type": "Name", "_fields": {"id": "_check", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}]}}}}]}}], "func": {"_type": "Name", "_fields": {"id": "_check", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}], "name": "testBroadcastingParams", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "student", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "arg", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "shape", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_shape", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "arg", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "log_pdf", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}, {"_type": "Name", "_fields": {"id": "shape", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_shape", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "arg", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "pdf", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}, {"_type": "Name", "_fields": {"id": "shape", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "name": "_assert_shape", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "student", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Name", "_fields": {"id": "_assert_shape", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "array", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "dtype", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "float32", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Name", "_fields": {"id": "_assert_shape", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "array", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Name", "_fields": {"id": "_assert_shape", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "T", "value": {"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Name", "_fields": {"id": "_assert_shape", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}], "name": "_check", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}]}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}]}}], "func": {"_type": "Name", "_fields": {"id": "_check", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}]}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}]}}], "func": {"_type": "Name", "_fields": {"id": "_check", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}]}}}}]}}], "func": {"_type": "Name", "_fields": {"id": "_check", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "student", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Name", "_fields": {"id": "_assert_shape", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "array", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "dtype", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "float32", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Name", "_fields": {"id": "_assert_shape", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "array", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Name", "_fields": {"id": "_assert_shape", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "T", "value": {"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Name", "_fields": {"id": "_assert_shape", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}], "name": "_check2d", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}]}}]}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}]}}], "func": {"_type": "Name", "_fields": {"id": "_check2d", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}]}}]}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}]}}], "func": {"_type": "Name", "_fields": {"id": "_check2d", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}]}}]}}}}]}}], "func": {"_type": "Name", "_fields": {"id": "_check2d", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "student", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}]}}], "func": {"_type": "Name", "_fields": {"id": "_assert_shape", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "array", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "dtype", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "float32", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Name", "_fields": {"id": "_assert_shape", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "array", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Name", "_fields": {"id": "_assert_shape", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "T", "value": {"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}]}}], "func": {"_type": "Name", "_fields": {"id": "_assert_shape", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}], "name": "_check2d_rows", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}]}}, {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}]}}, {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}]}}]}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}]}}], "func": {"_type": "Name", "_fields": {"id": "_check2d_rows", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}]}}, {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}]}}, {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}]}}]}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}]}}], "func": {"_type": "Name", "_fields": {"id": "_check2d_rows", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}]}}, {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}]}}, {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}]}}]}}}}]}}], "func": {"_type": "Name", "_fields": {"id": "_check2d_rows", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}], "name": "testBroadcastingPdfArgs", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.3}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.4}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 5.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}]}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}]}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mean", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "mean", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.3}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.4}}]}}, {"_type": "Name", "_fields": {"id": "mean", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "name": "testMeanAllowNanStatsIsFalseWorksWhenAllBatchMembersAreDefined", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.3}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.4}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 0.5}}, {"_type": "Constant", "_fields": {"kind": null, "value": 5.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}]}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}]}}}}, {"_type": "keyword", "_fields": {"arg": "allow_nan_stats", "value": {"_type": "Constant", "_fields": {"kind": null, "value": false}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "With", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mean", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "x < y"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertRaisesOpError", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "name": "testMeanAllowNanStatsIsFalseRaisesWhenBatchMemberIsUndefined", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 2}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.3}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.4}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 0.5}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 5.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}]}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 5.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}]}}}}, {"_type": "keyword", "_fields": {"arg": "allow_nan_stats", "value": {"_type": "Constant", "_fields": {"kind": null, "value": true}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mean", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "mean", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "nan", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "nan", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.3}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.4}}]}}, {"_type": "Name", "_fields": {"id": "mean", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "name": "testMeanAllowNanStatsIsTrueReturnsNaNForUndefinedBatchMembers", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 0.5}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1.5}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 5.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 2}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.3}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.4}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 5.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "allow_nan_stats", "value": {"_type": "Constant", "_fields": {"kind": null, "value": true}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "variance", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "var", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "var", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "isnan", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertTrue", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "inf", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "var", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "ListComp", "_fields": {"elt": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "d", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "var", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "t", "value": {"_type": "Name", "_fields": {"id": "stats", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "loc", "value": {"_type": "Name", "_fields": {"id": "m", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "scale", "value": {"_type": "Name", "_fields": {"id": "s", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "generators": [{"_type": "comprehension", "_fields": {"ifs": [], "iter": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "zip", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "target": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "d", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "m", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "s", "ctx": {"_type": "Store", "_fields": {}}}}]}}, "is_async": 0}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "expected_var", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "expected_var", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "var", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "name": "testVarianceAllowNanStatsTrueReturnsNaNforUndefinedBatchMembers", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 1.5}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 5.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 0.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.3}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.4}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "variance", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "var", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "ListComp", "_fields": {"elt": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "d", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "var", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "t", "value": {"_type": "Name", "_fields": {"id": "stats", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "loc", "value": {"_type": "Name", "_fields": {"id": "m", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "scale", "value": {"_type": "Name", "_fields": {"id": "s", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "generators": [{"_type": "comprehension", "_fields": {"ifs": [], "iter": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "zip", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "target": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "d", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "m", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "s", "ctx": {"_type": "Store", "_fields": {}}}}]}}, "is_async": 0}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "expected_var", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "expected_var", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "var", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "name": "testVarianceAllowNanStatsFalseGivesCorrectValueForDefinedBatchMembers", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.0}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}, {"_type": "keyword", "_fields": {"arg": "allow_nan_stats", "value": {"_type": "Constant", "_fields": {"kind": null, "value": false}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "With", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "variance", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "x < y"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertRaisesOpError", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}, {"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.5}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.0}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}, {"_type": "keyword", "_fields": {"arg": "allow_nan_stats", "value": {"_type": "Constant", "_fields": {"kind": null, "value": false}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "With", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "variance", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "x < y"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertRaisesOpError", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "name": "testVarianceAllowNanStatsFalseRaisesForUndefinedBatchMembers", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3.5}}, {"_type": "Constant", "_fields": {"kind": null, "value": 5.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 5.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 2.2}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 5.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "std", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "std", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "AugAssign", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "len", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "target": {"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Store", "_fields": {}}}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "ListComp", "_fields": {"elt": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "d", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "std", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "t", "value": {"_type": "Name", "_fields": {"id": "stats", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "loc", "value": {"_type": "Name", "_fields": {"id": "m", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "scale", "value": {"_type": "Name", "_fields": {"id": "s", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "generators": [{"_type": "comprehension", "_fields": {"ifs": [], "iter": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "zip", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "target": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "d", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "m", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "s", "ctx": {"_type": "Store", "_fields": {}}}}]}}, "is_async": 0}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "expected_std", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "expected_std", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "std", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "name": "testStd", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 0.5}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}]}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 5.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}]}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mode", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "mode", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}]}}, {"_type": "Name", "_fields": {"id": "mode", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "name": "testMode", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "pi", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": 20000}}, "targets": [{"_type": "Name", "_fields": {"id": "num", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "num", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sample", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "samples", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "samples", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "pdf", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "pdfs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mean", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "mean", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mean", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "pdf", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "mean_pdf", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "samples", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "pdfs", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mean", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Name", "_fields": {"id": "mean_pdf", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "run", "value": {"_type": "Name", "_fields": {"id": "sess", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "sample_vals", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "pdf_vals", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "mean_val", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "mean_pdf_val", "ctx": {"_type": "Store", "_fields": {}}}}]}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_shape", "value": {"_type": "Name", "_fields": {"id": "samples", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "num", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_shape", "value": {"_type": "Name", "_fields": {"id": "pdfs", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "num", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_shape", "value": {"_type": "Name", "_fields": {"id": "mean", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "pi", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "sample_vals", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mean", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertNear", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "err", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.02}}}}]}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "pi", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Name", "_fields": {"id": "mean_val", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertNear", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "err", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.000001}}}}]}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "pi", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "pdf", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "t", "value": {"_type": "Name", "_fields": {"id": "stats", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "loc", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "pi", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}}}]}}, {"_type": "Name", "_fields": {"id": "mean_pdf_val", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertNear", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "err", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.000001}}}}]}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "sample_vals", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "pdf_vals", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_assertIntegral", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": {"_type": "Name", "_fields": {"id": "sess", "ctx": {"_type": "Store", "_fields": {}}}}}}], "type_comment": null}}], "name": "testPdfOfSample", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 11.0}}]}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 5.0}}]}}, {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 6.0}}]}}]}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": 50000}}, "targets": [{"_type": "Name", "_fields": {"id": "num", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "num", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sample", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "samples", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "samples", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "pdf", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "pdfs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "samples", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "pdfs", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "run", "value": {"_type": "Name", "_fields": {"id": "sess", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "sample_vals", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "pdf_vals", "ctx": {"_type": "Store", "_fields": {}}}}]}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_shape", "value": {"_type": "Name", "_fields": {"id": "samples", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "num", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_shape", "value": {"_type": "Name", "_fields": {"id": "pdfs", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "num", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 5.0}}, {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, {"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}]}}, "value": {"_type": "Name", "_fields": {"id": "sample_vals", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mean", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertNear", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "err", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.03}}}}]}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 6.0}}, {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}, {"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}]}}, "value": {"_type": "Name", "_fields": {"id": "sample_vals", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mean", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertNear", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "err", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.03}}}}]}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "var", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "t", "value": {"_type": "Name", "_fields": {"id": "stats", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "loc", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.0}}}}, {"_type": "keyword", "_fields": {"arg": "scale", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}}}]}}, {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}]}}, "value": {"_type": "Name", "_fields": {"id": "sample_vals", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "var", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertNear", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "err", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.3}}}}]}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 11.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "var", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "t", "value": {"_type": "Name", "_fields": {"id": "stats", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "loc", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.0}}}}, {"_type": "keyword", "_fields": {"arg": "scale", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}}}]}}, {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}]}}, "value": {"_type": "Name", "_fields": {"id": "sample_vals", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "var", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertNear", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "err", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.3}}}}]}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}]}}, "value": {"_type": "Name", "_fields": {"id": "sample_vals", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}]}}, "value": {"_type": "Name", "_fields": {"id": "pdf_vals", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_assertIntegral", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "err", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.02}}}}]}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}]}}, "value": {"_type": "Name", "_fields": {"id": "sample_vals", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}]}}, "value": {"_type": "Name", "_fields": {"id": "pdf_vals", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_assertIntegral", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "err", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.02}}}}]}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}]}}, "value": {"_type": "Name", "_fields": {"id": "sample_vals", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}]}}, "value": {"_type": "Name", "_fields": {"id": "pdf_vals", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_assertIntegral", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "err", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.02}}}}]}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}]}}, "value": {"_type": "Name", "_fields": {"id": "sample_vals", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}]}}, "value": {"_type": "Name", "_fields": {"id": "pdf_vals", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_assertIntegral", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "err", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.02}}}}]}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": {"_type": "Name", "_fields": {"id": "sess", "ctx": {"_type": "Store", "_fields": {}}}}}}], "type_comment": null}}], "name": "testPdfOfSampleMultiDims", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "sample_vals", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "pdf_vals", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "err", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [{"_type": "Constant", "_fields": {"kind": null, "value": 0.001}}], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "sample_vals", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "pdf_vals", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "zip", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "s_p", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "BinOp", "_fields": {"op": {"_type": "Sub", "_fields": {}}, "left": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "min", "value": {"_type": "Name", "_fields": {"id": "sample_vals", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": 1000}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "prev", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "targets": [{"_type": "Name", "_fields": {"id": "total", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "For", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Div", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}, "value": {"_type": "Name", "_fields": {"id": "k", "ctx": {"_type": "Load", "_fields": {}}}}}}, "right": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}, "value": {"_type": "Name", "_fields": {"id": "prev", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": 2}}}}, "targets": [{"_type": "Name", "_fields": {"id": "pair_pdf", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "AugAssign", "_fields": {"op": {"_type": "Add", "_fields": {}}, "value": {"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Sub", "_fields": {}}, "left": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "k", "ctx": {"_type": "Load", "_fields": {}}}}}}, "right": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "prev", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "right": {"_type": "Name", "_fields": {"id": "pair_pdf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "target": {"_type": "Name", "_fields": {"id": "total", "ctx": {"_type": "Store", "_fields": {}}}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Name", "_fields": {"id": "k", "ctx": {"_type": "Load", "_fields": {}}}}, "targets": [{"_type": "Name", "_fields": {"id": "prev", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}], "iter": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "s_p", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "sorted", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "key", "value": {"_type": "Lambda", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "x", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "x", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}]}}, "orelse": [], "target": {"_type": "Name", "_fields": {"id": "k", "ctx": {"_type": "Store", "_fields": {}}}}, "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}, {"_type": "Name", "_fields": {"id": "total", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertNear", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "err", "value": {"_type": "Name", "_fields": {"id": "err", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}}}], "name": "_assertIntegral", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2}}, {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 5.0}}}}]}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.0}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}, {"_type": "keyword", "_fields": {"arg": "validate_args", "value": {"_type": "Constant", "_fields": {"kind": null, "value": true}}}}, {"_type": "keyword", "_fields": {"arg": "name", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "S"}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "With", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mean", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "Condition x > 0 did not hold"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertRaisesOpError", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "name": "testNegativeDofFails", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 5.0}}]}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.0}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}]}}, {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}}}]}}]}}}}, {"_type": "keyword", "_fields": {"arg": "validate_args", "value": {"_type": "Constant", "_fields": {"kind": null, "value": true}}}}, {"_type": "keyword", "_fields": {"arg": "name", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "S"}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "With", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mean", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "Condition x > 0 did not hold"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertRaisesOpError", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "name": "testNegativeScaleFails", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 3.2}}}}, {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 4.6}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 4.2}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.4}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 6.4}}}}, {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 8.8}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentTWithAbsDfSoftplusSigma", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "abs", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "floor", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}, {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "df", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mu", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "softplus", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "nn", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}, "keywords": []}}, {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sigma", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "name": "testStudentTWithAbsDfSoftplusSigma", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "name": "StudentTTest", "bases": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "TestCase", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "keywords": [], "type_params": [], "decorator_list": []}}], "type_ignores": []}}
class StudentTTest(tf.test.TestCase): def testStudentPDFAndLogPDF(self): with self.test_session(): batch_size = 6 df = tf.constant([3.0] * batch_size) mu = tf.constant([7.0] * batch_size) sigma = tf.constant([8.0] * batch_size) df_v = 3.0 mu_v = 7.0 sigma_v = 8.0 t = np.array([-2.5, 2.5, 8.0, 0.0, -1.0, 2.0], dtype=np.float32) student = tf.contrib.distributions.StudentT(df, mu=mu, sigma=sigma) log_pdf = student.log_pdf(t) self.assertEquals(log_pdf.get_shape(), (6,)) log_pdf_values = log_pdf.eval() pdf = student.pdf(t) self.assertEquals(pdf.get_shape(), (6,)) pdf_values = pdf.eval() expected_log_pdf = stats.t.logpdf(t, df_v, loc=mu_v, scale=sigma_v) expected_pdf = stats.t.pdf(t, df_v, loc=mu_v, scale=sigma_v) self.assertAllClose(expected_log_pdf, log_pdf_values) self.assertAllClose(np.log(expected_pdf), log_pdf_values) self.assertAllClose(expected_pdf, pdf_values) self.assertAllClose(np.exp(expected_log_pdf), pdf_values) def testStudentLogPDFMultidimensional(self): with self.test_session(): batch_size = 6 df = tf.constant([[1.5, 7.2]] * batch_size) mu = tf.constant([[3.0, -3.0]] * batch_size) sigma = tf.constant([[math.sqrt(10.0), math.sqrt(15.0)]] * batch_size) df_v = np.array([1.5, 7.2]) mu_v = np.array([3.0, -3.0]) sigma_v = np.array([np.sqrt(10.0), np.sqrt(15.0)]) t = np.array([[-2.5, 2.5, 4.0, 0.0, -1.0, 2.0]], dtype=np.float32).T student = tf.contrib.distributions.StudentT(df, mu=mu, sigma=sigma) log_pdf = student.log_pdf(t) log_pdf_values = log_pdf.eval() self.assertEqual(log_pdf.get_shape(), (6, 2)) pdf = student.pdf(t) pdf_values = pdf.eval() self.assertEqual(pdf.get_shape(), (6, 2)) expected_log_pdf = stats.t.logpdf(t, df_v, loc=mu_v, scale=sigma_v) expected_pdf = stats.t.pdf(t, df_v, loc=mu_v, scale=sigma_v) self.assertAllClose(expected_log_pdf, log_pdf_values) self.assertAllClose(np.log(expected_pdf), log_pdf_values) self.assertAllClose(expected_pdf, pdf_values) self.assertAllClose(np.exp(expected_log_pdf), pdf_values) def testStudentEntropy(self): df_v = np.array([[2., 3., 7.]]) # 1x3 mu_v = np.array([[1., -1, 0]]) # 1x3 sigma_v = np.array([[1., 2., 3.]]).T # transposed => 3x1 with self.test_session(): student = tf.contrib.distributions.StudentT(df=df_v, mu=mu_v, sigma=sigma_v) ent = student.entropy() ent_values = ent.eval() # Help scipy broadcast to 3x3 ones = np.array([[1, 1, 1]]) sigma_bc = sigma_v * ones mu_bc = ones.T * mu_v df_bc = ones.T * df_v expected_entropy = stats.t.entropy( np.reshape(df_bc, [-1]), loc=np.reshape(mu_bc, [-1]), scale=np.reshape(sigma_bc, [-1])) expected_entropy = np.reshape(expected_entropy, df_bc.shape) self.assertAllClose(expected_entropy, ent_values) def testStudentSample(self): with self.test_session(): df = tf.constant(4.0) mu = tf.constant(3.0) sigma = tf.constant(math.sqrt(10.0)) df_v = 4.0 mu_v = 3.0 sigma_v = np.sqrt(10.0) n = tf.constant(200000) student = tf.contrib.distributions.StudentT(df=df, mu=mu, sigma=sigma) samples = student.sample(n) sample_values = samples.eval() n_val = 200000 self.assertEqual(sample_values.shape, (n_val,)) self.assertAllClose(sample_values.mean(), mu_v, rtol=1e-2, atol=0) self.assertAllClose(sample_values.var(), sigma_v**2 * df_v / (df_v - 2), rtol=1e-2, atol=0) self._checkKLApprox(df_v, mu_v, sigma_v, sample_values) # Test that sampling with the same seed twice gives the same results. def testStudentSampleMultipleTimes(self): with self.test_session(): df = tf.constant(4.0) mu = tf.constant(3.0) sigma = tf.constant(math.sqrt(10.0)) df_v = 4.0 mu_v = 3.0 sigma_v = np.sqrt(10.0) n = tf.constant(100) tf.set_random_seed(654321) student = tf.contrib.distributions.StudentT( df=df, mu=mu, sigma=sigma, name="student_t1") samples1 = student.sample(n, seed=123456).eval() tf.set_random_seed(654321) student2 = tf.contrib.distributions.StudentT( df=df, mu=mu, sigma=sigma, name="student_t2") samples2 = student2.sample(n, seed=123456).eval() self.assertAllClose(samples1, samples2) def testStudentSampleSmallDfNoNan(self): with self.test_session(): df_v = [1e-1, 1e-5, 1e-10, 1e-20] df = tf.constant(df_v) n = tf.constant(200000) student = tf.contrib.distributions.StudentT(df=df, mu=1.0, sigma=1.0) samples = student.sample(n) sample_values = samples.eval() n_val = 200000 self.assertEqual(sample_values.shape, (n_val, 4)) self.assertTrue(np.all(np.logical_not(np.isnan(sample_values)))) def testStudentSampleMultiDimensional(self): with self.test_session(): batch_size = 7 df = tf.constant([[3.0, 7.0]] * batch_size) mu = tf.constant([[3.0, -3.0]] * batch_size) sigma = tf.constant([[math.sqrt(10.0), math.sqrt(15.0)]] * batch_size) df_v = [3.0, 7.0] mu_v = [3.0, -3.0] sigma_v = [np.sqrt(10.0), np.sqrt(15.0)] n = tf.constant(200000) student = tf.contrib.distributions.StudentT(df=df, mu=mu, sigma=sigma) samples = student.sample(n) sample_values = samples.eval() self.assertEqual(samples.get_shape(), (200000, batch_size, 2)) self.assertAllClose( sample_values[:, 0, 0].mean(), mu_v[0], rtol=1e-2, atol=0) self.assertAllClose(sample_values[:, 0, 0].var(), sigma_v[0]**2 * df_v[0] / (df_v[0] - 2), rtol=1e-1, atol=0) self._checkKLApprox(df_v[0], mu_v[0], sigma_v[0], sample_values[:, 0, 0]) self.assertAllClose( sample_values[:, 0, 1].mean(), mu_v[1], rtol=1e-2, atol=0) self.assertAllClose(sample_values[:, 0, 1].var(), sigma_v[1]**2 * df_v[1] / (df_v[1] - 2), rtol=1e-1, atol=0) self._checkKLApprox(df_v[0], mu_v[0], sigma_v[0], sample_values[:, 0, 1]) def _checkKLApprox(self, df, mu, sigma, samples): n = samples.size np.random.seed(137) sample_scipy = stats.t.rvs(df, loc=mu, scale=sigma, size=n) covg = 0.99 r = stats.t.interval(covg, df, loc=mu, scale=sigma) bins = 100 hist, _ = np.histogram(samples, bins=bins, range=r) hist_scipy, _ = np.histogram(sample_scipy, bins=bins, range=r) self.assertGreater(hist.sum(), n * (covg - .01)) self.assertGreater(hist_scipy.sum(), n * (covg - .01)) hist_min1 = hist + 1. # put at least one item in each bucket hist_norm = hist_min1 / hist_min1.sum() hist_scipy_min1 = hist_scipy + 1. # put at least one item in each bucket hist_scipy_norm = hist_scipy_min1 / hist_scipy_min1.sum() kl_appx = np.sum(np.log(hist_scipy_norm / hist_norm) * hist_scipy_norm) self.assertLess(kl_appx, 1) def testBroadcastingParams(self): def _check(student): self.assertEqual(student.mean().get_shape(), (3,)) self.assertEqual(student.variance().get_shape(), (3,)) self.assertEqual(student.entropy().get_shape(), (3,)) self.assertEqual(student.log_pdf(2.).get_shape(), (3,)) self.assertEqual(student.pdf(2.).get_shape(), (3,)) self.assertEqual(student.sample(37).get_shape(), (37, 3,)) _check(tf.contrib.distributions.StudentT(df=[2., 3., 4.,], mu=2., sigma=1.)) _check(tf.contrib.distributions.StudentT(df=7., mu=[2., 3., 4.,], sigma=1.)) _check(tf.contrib.distributions.StudentT(df=7., mu=3., sigma=[2., 3., 4.,])) def testBroadcastingPdfArgs(self): def _assert_shape(student, arg, shape): self.assertEqual(student.log_pdf(arg).get_shape(), shape) self.assertEqual(student.pdf(arg).get_shape(), shape) def _check(student): _assert_shape(student, 2., (3,)) xs = np.array([2., 3., 4.], dtype=np.float32) _assert_shape(student, xs, (3,)) xs = np.array([xs]) _assert_shape(student, xs, (1, 3)) xs = xs.T _assert_shape(student, xs, (3, 3)) _check(tf.contrib.distributions.StudentT(df=[2., 3., 4.,], mu=2., sigma=1.)) _check(tf.contrib.distributions.StudentT(df=7., mu=[2., 3., 4.,], sigma=1.)) _check(tf.contrib.distributions.StudentT(df=7., mu=3., sigma=[2., 3., 4.,])) def _check2d(student): _assert_shape(student, 2., (1, 3)) xs = np.array([2., 3., 4.], dtype=np.float32) _assert_shape(student, xs, (1, 3)) xs = np.array([xs]) _assert_shape(student, xs, (1, 3)) xs = xs.T _assert_shape(student, xs, (3, 3)) _check2d(tf.contrib.distributions.StudentT( df=[[2., 3., 4.,]], mu=2., sigma=1.)) _check2d(tf.contrib.distributions.StudentT( df=7., mu=[[2., 3., 4.,]], sigma=1.)) _check2d(tf.contrib.distributions.StudentT( df=7., mu=3., sigma=[[2., 3., 4.,]])) def _check2d_rows(student): _assert_shape(student, 2., (3, 1)) xs = np.array([2., 3., 4.], dtype=np.float32) # (3,) _assert_shape(student, xs, (3, 3)) xs = np.array([xs]) # (1,3) _assert_shape(student, xs, (3, 3)) xs = xs.T # (3,1) _assert_shape(student, xs, (3, 1)) _check2d_rows(tf.contrib.distributions.StudentT( df=[[2.], [3.], [4.]], mu=2., sigma=1.)) _check2d_rows(tf.contrib.distributions.StudentT( df=7., mu=[[2.], [3.], [4.]], sigma=1.)) _check2d_rows(tf.contrib.distributions.StudentT( df=7., mu=3., sigma=[[2.], [3.], [4.]])) def testMeanAllowNanStatsIsFalseWorksWhenAllBatchMembersAreDefined(self): with self.test_session(): mu = [1., 3.3, 4.4] student = tf.contrib.distributions.StudentT( df=[3., 5., 7.], mu=mu, sigma=[3., 2., 1.]) mean = student.mean().eval() self.assertAllClose([1., 3.3, 4.4], mean) def testMeanAllowNanStatsIsFalseRaisesWhenBatchMemberIsUndefined(self): with self.test_session(): mu = [1., 3.3, 4.4] student = tf.contrib.distributions.StudentT( df=[0.5, 5., 7.], mu=mu, sigma=[3., 2., 1.], allow_nan_stats=False) with self.assertRaisesOpError("x < y"): student.mean().eval() def testMeanAllowNanStatsIsTrueReturnsNaNForUndefinedBatchMembers(self): with self.test_session(): mu = [-2, 0., 1., 3.3, 4.4] student = tf.contrib.distributions.StudentT( df=[0.5, 1., 3., 5., 7.], mu=mu, sigma=[5., 4., 3., 2., 1.], allow_nan_stats=True) mean = student.mean().eval() self.assertAllClose([np.nan, np.nan, 1., 3.3, 4.4], mean) def testVarianceAllowNanStatsTrueReturnsNaNforUndefinedBatchMembers(self): with self.test_session(): # df = 0.5 ==> undefined mean ==> undefined variance. # df = 1.5 ==> infinite variance. df = [0.5, 1.5, 3., 5., 7.] mu = [-2, 0., 1., 3.3, 4.4] sigma = [5., 4., 3., 2., 1.] student = tf.contrib.distributions.StudentT( df=df, mu=mu, sigma=sigma, allow_nan_stats=True) var = student.variance().eval() ## scipy uses inf for variance when the mean is undefined. When mean is # undefined we say variance is undefined as well. So test the first # member of var, making sure it is NaN, then replace with inf and compare # to scipy. self.assertTrue(np.isnan(var[0])) var[0] = np.inf expected_var = [ stats.t.var(d, loc=m, scale=s) for (d, m, s) in zip(df, mu, sigma)] self.assertAllClose(expected_var, var) def testVarianceAllowNanStatsFalseGivesCorrectValueForDefinedBatchMembers( self): with self.test_session(): # df = 1.5 ==> infinite variance. df = [1.5, 3., 5., 7.] mu = [0., 1., 3.3, 4.4] sigma = [4., 3., 2., 1.] student = tf.contrib.distributions.StudentT( df=df, mu=mu, sigma=sigma) var = student.variance().eval() expected_var = [ stats.t.var(d, loc=m, scale=s) for (d, m, s) in zip(df, mu, sigma)] self.assertAllClose(expected_var, var) def testVarianceAllowNanStatsFalseRaisesForUndefinedBatchMembers(self): with self.test_session(): # df <= 1 ==> variance not defined student = tf.contrib.distributions.StudentT( df=1.0, mu=0.0, sigma=1.0, allow_nan_stats=False) with self.assertRaisesOpError("x < y"): student.variance().eval() with self.test_session(): # df <= 1 ==> variance not defined student = tf.contrib.distributions.StudentT( df=0.5, mu=0.0, sigma=1.0, allow_nan_stats=False) with self.assertRaisesOpError("x < y"): student.variance().eval() def testStd(self): with self.test_session(): # Defined for all batch members. df = [3.5, 5., 3., 5., 7.] mu = [-2.2] sigma = [5., 4., 3., 2., 1.] student = tf.contrib.distributions.StudentT(df=df, mu=mu, sigma=sigma) # Test broadcast of mu across shape of df/sigma std = student.std().eval() mu *= len(df) expected_std = [ stats.t.std(d, loc=m, scale=s) for (d, m, s) in zip(df, mu, sigma)] self.assertAllClose(expected_std, std) def testMode(self): with self.test_session(): student = tf.contrib.distributions.StudentT( df=[0.5, 1., 3], mu=[-1, 0., 1], sigma=[5., 4., 3.]) # Test broadcast of mu across shape of df/sigma mode = student.mode().eval() self.assertAllClose([-1., 0, 1], mode) def testPdfOfSample(self): with self.test_session() as sess: student = tf.contrib.distributions.StudentT(df=3., mu=np.pi, sigma=1.) num = 20000 samples = student.sample(num) pdfs = student.pdf(samples) mean = student.mean() mean_pdf = student.pdf(student.mean()) sample_vals, pdf_vals, mean_val, mean_pdf_val = sess.run( [samples, pdfs, student.mean(), mean_pdf]) self.assertEqual(samples.get_shape(), (num,)) self.assertEqual(pdfs.get_shape(), (num,)) self.assertEqual(mean.get_shape(), ()) self.assertNear(np.pi, np.mean(sample_vals), err=0.02) self.assertNear(np.pi, mean_val, err=1e-6) self.assertNear(stats.t.pdf(np.pi, 3., loc=np.pi), mean_pdf_val, err=1e-6) # Verify integral over sample*pdf ~= 1. self._assertIntegral(sample_vals, pdf_vals) def testPdfOfSampleMultiDims(self): with self.test_session() as sess: student = tf.contrib.distributions.StudentT(df=[7., 11.], mu=[[5.], [6.]], sigma=3.) num = 50000 samples = student.sample(num) pdfs = student.pdf(samples) sample_vals, pdf_vals = sess.run([samples, pdfs]) self.assertEqual(samples.get_shape(), (num, 2, 2)) self.assertEqual(pdfs.get_shape(), (num, 2, 2)) self.assertNear(5., np.mean(sample_vals[:, 0, :]), err=.03) self.assertNear(6., np.mean(sample_vals[:, 1, :]), err=.03) self.assertNear(stats.t.var(7., loc=0., scale=3.), # loc d.n. effect var np.var(sample_vals[:, :, 0]), err=.3) self.assertNear(stats.t.var(11., loc=0., scale=3.), # loc d.n. effect var np.var(sample_vals[:, :, 1]), err=.3) self._assertIntegral(sample_vals[:, 0, 0], pdf_vals[:, 0, 0], err=0.02) self._assertIntegral(sample_vals[:, 0, 1], pdf_vals[:, 0, 1], err=0.02) self._assertIntegral(sample_vals[:, 1, 0], pdf_vals[:, 1, 0], err=0.02) self._assertIntegral(sample_vals[:, 1, 1], pdf_vals[:, 1, 1], err=0.02) def _assertIntegral(self, sample_vals, pdf_vals, err=1e-3): s_p = zip(sample_vals, pdf_vals) prev = (sample_vals.min() - 1000, 0) total = 0 for k in sorted(s_p, key=lambda x: x[0]): pair_pdf = (k[1] + prev[1]) / 2 total += (k[0] - prev[0]) * pair_pdf prev = k self.assertNear(1., total, err=err) def testNegativeDofFails(self): with self.test_session(): student = tf.contrib.distributions.StudentT(df=[2, -5.], mu=0., sigma=1., validate_args=True, name="S") with self.assertRaisesOpError(r"Condition x > 0 did not hold"): student.mean().eval() def testNegativeScaleFails(self): with self.test_session(): student = tf.contrib.distributions.StudentT(df=[5.], mu=0., sigma=[[3.], [-2.]], validate_args=True, name="S") with self.assertRaisesOpError(r"Condition x > 0 did not hold"): student.mean().eval() def testStudentTWithAbsDfSoftplusSigma(self): with self.test_session(): df = tf.constant([-3.2, -4.6]) mu = tf.constant([-4.2, 3.4]) sigma = tf.constant([-6.4, -8.8]) student = tf.contrib.distributions.StudentTWithAbsDfSoftplusSigma( df=df, mu=mu, sigma=sigma) self.assertAllClose(tf.floor(tf.abs(df)).eval(), student.df.eval()) self.assertAllClose(mu.eval(), student.mu.eval()) self.assertAllClose(tf.nn.softplus(sigma).eval(), student.sigma.eval())
14,453
[ -0.0035808244720101357, -0.03040873073041439, 0.012120629660785198, -0.045648813247680664, -0.012477818876504898, 0.012132535688579082, 0.04657750576734543, 0.026432020589709282, 0.03028966672718525, 0.022669624537229538, 0.024229351431131363, 0.01379941962659359, -0.02845609374344349, 0.0...
10
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": 6}}, "targets": [{"_type": "Name", "_fields": {"id": "batch_size", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}]}}, "right": {"_type": "Name", "_fields": {"id": "batch_size", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}]}}, "right": {"_type": "Name", "_fields": {"id": "batch_size", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 8.0}}]}}, "right": {"_type": "Name", "_fields": {"id": "batch_size", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, "targets": [{"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}, "targets": [{"_type": "Name", "_fields": {"id": "mu_v", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": 8.0}}, "targets": [{"_type": "Name", "_fields": {"id": "sigma_v", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 2.5}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2.5}}, {"_type": "Constant", "_fields": {"kind": null, "value": 8.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0.0}}, {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "array", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "dtype", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "float32", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "t", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "t", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "log_pdf", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "log_pdf", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_shape", "value": {"_type": "Name", "_fields": {"id": "log_pdf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 6}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEquals", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Name", "_fields": {"id": "log_pdf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "log_pdf_values", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "t", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "pdf", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "pdf", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_shape", "value": {"_type": "Name", "_fields": {"id": "pdf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 6}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEquals", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Name", "_fields": {"id": "pdf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "pdf_values", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "t", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "logpdf", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "t", "value": {"_type": "Name", "_fields": {"id": "stats", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "loc", "value": {"_type": "Name", "_fields": {"id": "mu_v", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "scale", "value": {"_type": "Name", "_fields": {"id": "sigma_v", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "expected_log_pdf", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "t", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "pdf", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "t", "value": {"_type": "Name", "_fields": {"id": "stats", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "loc", "value": {"_type": "Name", "_fields": {"id": "mu_v", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "scale", "value": {"_type": "Name", "_fields": {"id": "sigma_v", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "expected_pdf", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "expected_log_pdf", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "log_pdf_values", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "expected_pdf", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "log", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Name", "_fields": {"id": "log_pdf_values", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "expected_pdf", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "pdf_values", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "expected_log_pdf", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "exp", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Name", "_fields": {"id": "pdf_values", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "name": "testStudentPDFAndLogPDF", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def testStudentPDFAndLogPDF(self): with self.test_session(): batch_size = 6 df = tf.constant([3.0] * batch_size) mu = tf.constant([7.0] * batch_size) sigma = tf.constant([8.0] * batch_size) df_v = 3.0 mu_v = 7.0 sigma_v = 8.0 t = np.array([-2.5, 2.5, 8.0, 0.0, -1.0, 2.0], dtype=np.float32) student = tf.contrib.distributions.StudentT(df, mu=mu, sigma=sigma) log_pdf = student.log_pdf(t) self.assertEquals(log_pdf.get_shape(), (6,)) log_pdf_values = log_pdf.eval() pdf = student.pdf(t) self.assertEquals(pdf.get_shape(), (6,)) pdf_values = pdf.eval() expected_log_pdf = stats.t.logpdf(t, df_v, loc=mu_v, scale=sigma_v) expected_pdf = stats.t.pdf(t, df_v, loc=mu_v, scale=sigma_v) self.assertAllClose(expected_log_pdf, log_pdf_values) self.assertAllClose(np.log(expected_pdf), log_pdf_values) self.assertAllClose(expected_pdf, pdf_values) self.assertAllClose(np.exp(expected_log_pdf), pdf_values)
14,454
[ -0.00838255975395441, -0.022751782089471817, 0.025375567376613617, -0.024316199123859406, -0.010667592287063599, 0.011572983115911484, 0.03219987079501152, 0.030105769634246826, 0.02007872425019741, 0.03651125356554985, 0.027543576434254646, 0.0067442343570292, -0.017257848754525185, 0.029...
12
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": 6}}, "targets": [{"_type": "Name", "_fields": {"id": "batch_size", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 1.5}}, {"_type": "Constant", "_fields": {"kind": null, "value": 7.2}}]}}]}}, "right": {"_type": "Name", "_fields": {"id": "batch_size", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}}}]}}]}}, "right": {"_type": "Name", "_fields": {"id": "batch_size", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 10.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sqrt", "value": {"_type": "Name", "_fields": {"id": "math", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 15.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sqrt", "value": {"_type": "Name", "_fields": {"id": "math", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}]}}]}}, "right": {"_type": "Name", "_fields": {"id": "batch_size", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 1.5}}, {"_type": "Constant", "_fields": {"kind": null, "value": 7.2}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "array", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "array", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "mu_v", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 10.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sqrt", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 15.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sqrt", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "array", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "sigma_v", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "T", "value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 2.5}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2.5}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0.0}}, {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}]}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "array", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "dtype", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "float32", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}}}]}}}}, "targets": [{"_type": "Name", "_fields": {"id": "t", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "t", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "log_pdf", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "log_pdf", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Name", "_fields": {"id": "log_pdf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "log_pdf_values", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_shape", "value": {"_type": "Name", "_fields": {"id": "log_pdf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 6}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "t", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "pdf", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "pdf", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Name", "_fields": {"id": "pdf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "pdf_values", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_shape", "value": {"_type": "Name", "_fields": {"id": "pdf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 6}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "t", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "logpdf", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "t", "value": {"_type": "Name", "_fields": {"id": "stats", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "loc", "value": {"_type": "Name", "_fields": {"id": "mu_v", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "scale", "value": {"_type": "Name", "_fields": {"id": "sigma_v", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "expected_log_pdf", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "t", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "pdf", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "t", "value": {"_type": "Name", "_fields": {"id": "stats", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "loc", "value": {"_type": "Name", "_fields": {"id": "mu_v", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "scale", "value": {"_type": "Name", "_fields": {"id": "sigma_v", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "expected_pdf", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "expected_log_pdf", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "log_pdf_values", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "expected_pdf", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "log", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Name", "_fields": {"id": "log_pdf_values", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "expected_pdf", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "pdf_values", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "expected_log_pdf", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "exp", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Name", "_fields": {"id": "pdf_values", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "name": "testStudentLogPDFMultidimensional", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def testStudentLogPDFMultidimensional(self): with self.test_session(): batch_size = 6 df = tf.constant([[1.5, 7.2]] * batch_size) mu = tf.constant([[3.0, -3.0]] * batch_size) sigma = tf.constant([[math.sqrt(10.0), math.sqrt(15.0)]] * batch_size) df_v = np.array([1.5, 7.2]) mu_v = np.array([3.0, -3.0]) sigma_v = np.array([np.sqrt(10.0), np.sqrt(15.0)]) t = np.array([[-2.5, 2.5, 4.0, 0.0, -1.0, 2.0]], dtype=np.float32).T student = tf.contrib.distributions.StudentT(df, mu=mu, sigma=sigma) log_pdf = student.log_pdf(t) log_pdf_values = log_pdf.eval() self.assertEqual(log_pdf.get_shape(), (6, 2)) pdf = student.pdf(t) pdf_values = pdf.eval() self.assertEqual(pdf.get_shape(), (6, 2)) expected_log_pdf = stats.t.logpdf(t, df_v, loc=mu_v, scale=sigma_v) expected_pdf = stats.t.pdf(t, df_v, loc=mu_v, scale=sigma_v) self.assertAllClose(expected_log_pdf, log_pdf_values) self.assertAllClose(np.log(expected_pdf), log_pdf_values) self.assertAllClose(expected_pdf, pdf_values) self.assertAllClose(np.exp(expected_log_pdf), pdf_values)
14,455
[ -0.0007111552404239774, -0.03678622469305992, 0.06688841432332993, -0.017190948128700256, 0.0005605090409517288, -0.016637952998280525, 0.01707073114812374, 0.04318173974752426, 0.03967141732573509, 0.03616109862923622, 0.00884792860597372, 0.015231420285999775, -0.02103787288069725, 0.051...
10
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}]}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "array", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}, {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}]}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "array", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "mu_v", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "T", "value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}]}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "array", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "sigma_v", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Name", "_fields": {"id": "mu_v", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Name", "_fields": {"id": "sigma_v", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "entropy", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "ent", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Name", "_fields": {"id": "ent", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "ent_values", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}]}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "array", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "ones", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "sigma_v", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "Name", "_fields": {"id": "ones", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "sigma_bc", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "T", "value": {"_type": "Name", "_fields": {"id": "ones", "ctx": {"_type": "Load", "_fields": {}}}}}}, "right": {"_type": "Name", "_fields": {"id": "mu_v", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "mu_bc", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "T", "value": {"_type": "Name", "_fields": {"id": "ones", "ctx": {"_type": "Load", "_fields": {}}}}}}, "right": {"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "df_bc", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "df_bc", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "reshape", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "entropy", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "t", "value": {"_type": "Name", "_fields": {"id": "stats", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "loc", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "mu_bc", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "reshape", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "keyword", "_fields": {"arg": "scale", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "sigma_bc", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "reshape", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "expected_entropy", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "expected_entropy", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "shape", "value": {"_type": "Name", "_fields": {"id": "df_bc", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "reshape", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "expected_entropy", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "expected_entropy", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "ent_values", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "name": "testStudentEntropy", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def testStudentEntropy(self): df_v = np.array([[2., 3., 7.]]) # 1x3 mu_v = np.array([[1., -1, 0]]) # 1x3 sigma_v = np.array([[1., 2., 3.]]).T # transposed => 3x1 with self.test_session(): student = tf.contrib.distributions.StudentT(df=df_v, mu=mu_v, sigma=sigma_v) ent = student.entropy() ent_values = ent.eval() # Help scipy broadcast to 3x3 ones = np.array([[1, 1, 1]]) sigma_bc = sigma_v * ones mu_bc = ones.T * mu_v df_bc = ones.T * df_v expected_entropy = stats.t.entropy( np.reshape(df_bc, [-1]), loc=np.reshape(mu_bc, [-1]), scale=np.reshape(sigma_bc, [-1])) expected_entropy = np.reshape(expected_entropy, df_bc.shape) self.assertAllClose(expected_entropy, ent_values)
14,456
[ 0.008447534404695034, -0.054924603551626205, 0.06933105736970901, -0.02162218652665615, -0.007284513209015131, 0.008491303771734238, 0.03729170560836792, 0.005746324080973864, 0.02606167457997799, 0.029863378033041954, 0.01795804500579834, 0.00004259720662957989, -0.023222902789711952, 0.0...
10
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 10.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sqrt", "value": {"_type": "Name", "_fields": {"id": "math", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}, "targets": [{"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, "targets": [{"_type": "Name", "_fields": {"id": "mu_v", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 10.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sqrt", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "sigma_v", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 100}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "n", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 654321}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "set_random_seed", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "name", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "student_t1"}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "n", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sample", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "seed", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 123456}}}}]}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "samples1", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 654321}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "set_random_seed", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "name", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "student_t2"}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student2", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "n", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sample", "value": {"_type": "Name", "_fields": {"id": "student2", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "seed", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 123456}}}}]}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "samples2", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "samples1", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "samples2", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "name": "testStudentSampleMultipleTimes", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def testStudentSampleMultipleTimes(self): with self.test_session(): df = tf.constant(4.0) mu = tf.constant(3.0) sigma = tf.constant(math.sqrt(10.0)) df_v = 4.0 mu_v = 3.0 sigma_v = np.sqrt(10.0) n = tf.constant(100) tf.set_random_seed(654321) student = tf.contrib.distributions.StudentT( df=df, mu=mu, sigma=sigma, name="student_t1") samples1 = student.sample(n, seed=123456).eval() tf.set_random_seed(654321) student2 = tf.contrib.distributions.StudentT( df=df, mu=mu, sigma=sigma, name="student_t2") samples2 = student2.sample(n, seed=123456).eval() self.assertAllClose(samples1, samples2)
14,457
[ -0.01146302092820406, -0.03663182631134987, 0.011930263601243496, 0.0004991709138266742, 0.0036320332437753677, -0.010640673339366913, 0.004582093097269535, 0.0182411540299654, 0.019848469644784927, 0.04353455826640129, 0.02414710260927677, -0.00024121403112076223, -0.032868966460227966, 0...
10
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 10.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sqrt", "value": {"_type": "Name", "_fields": {"id": "math", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}, "targets": [{"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, "targets": [{"_type": "Name", "_fields": {"id": "mu_v", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 10.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sqrt", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "sigma_v", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 200000}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "n", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "n", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sample", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "samples", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Name", "_fields": {"id": "samples", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "sample_values", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": 200000}}, "targets": [{"_type": "Name", "_fields": {"id": "n_val", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "shape", "value": {"_type": "Name", "_fields": {"id": "sample_values", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "n_val", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mean", "value": {"_type": "Name", "_fields": {"id": "sample_values", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Name", "_fields": {"id": "mu_v", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "rtol", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.01}}}}, {"_type": "keyword", "_fields": {"arg": "atol", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}}}]}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "var", "value": {"_type": "Name", "_fields": {"id": "sample_values", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "BinOp", "_fields": {"op": {"_type": "Div", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Pow", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "sigma_v", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": 2}}}}, "right": {"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Load", "_fields": {}}}}}}, "right": {"_type": "BinOp", "_fields": {"op": {"_type": "Sub", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": 2}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "rtol", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.01}}}}, {"_type": "keyword", "_fields": {"arg": "atol", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}}}]}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "mu_v", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "sigma_v", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "sample_values", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_checkKLApprox", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "name": "testStudentSample", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def testStudentSample(self): with self.test_session(): df = tf.constant(4.0) mu = tf.constant(3.0) sigma = tf.constant(math.sqrt(10.0)) df_v = 4.0 mu_v = 3.0 sigma_v = np.sqrt(10.0) n = tf.constant(200000) student = tf.contrib.distributions.StudentT(df=df, mu=mu, sigma=sigma) samples = student.sample(n) sample_values = samples.eval() n_val = 200000 self.assertEqual(sample_values.shape, (n_val,)) self.assertAllClose(sample_values.mean(), mu_v, rtol=1e-2, atol=0) self.assertAllClose(sample_values.var(), sigma_v**2 * df_v / (df_v - 2), rtol=1e-2, atol=0) self._checkKLApprox(df_v, mu_v, sigma_v, sample_values)
14,458
[ 0.019418301060795784, -0.04844890162348747, 0.007045792415738106, -0.023619141429662704, 0.01541115716099739, -0.02359492890536785, 0.012699374929070473, 0.008692231960594654, 0.014236859045922756, 0.034236256033182144, 0.023994432762265205, -0.007699525449424982, -0.046100303530693054, 0....
11
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 0.1}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0.00001}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0.0000000001}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0.00000000000000000001}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 200000}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "n", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "n", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sample", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "samples", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Name", "_fields": {"id": "samples", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "sample_values", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": 200000}}, "targets": [{"_type": "Name", "_fields": {"id": "n_val", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "shape", "value": {"_type": "Name", "_fields": {"id": "sample_values", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "n_val", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "sample_values", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "isnan", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "logical_not", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "all", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertTrue", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "name": "testStudentSampleSmallDfNoNan", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def testStudentSampleSmallDfNoNan(self): with self.test_session(): df_v = [1e-1, 1e-5, 1e-10, 1e-20] df = tf.constant(df_v) n = tf.constant(200000) student = tf.contrib.distributions.StudentT(df=df, mu=1.0, sigma=1.0) samples = student.sample(n) sample_values = samples.eval() n_val = 200000 self.assertEqual(sample_values.shape, (n_val, 4)) self.assertTrue(np.all(np.logical_not(np.isnan(sample_values))))
14,459
[ -0.0016809722874313593, -0.04944664239883423, 0.04208865761756897, -0.01290785800665617, -0.0005520840641111135, -0.003562845289707184, 0.014791300520300865, 0.014150930568575859, -0.01393747329711914, 0.04583043232560158, 0.005986207630485296, -0.006516710855066776, -0.017842477187514305, ...
12
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": 7}}, "targets": [{"_type": "Name", "_fields": {"id": "batch_size", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}]}}]}}, "right": {"_type": "Name", "_fields": {"id": "batch_size", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}}}]}}]}}, "right": {"_type": "Name", "_fields": {"id": "batch_size", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 10.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sqrt", "value": {"_type": "Name", "_fields": {"id": "math", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 15.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sqrt", "value": {"_type": "Name", "_fields": {"id": "math", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}]}}]}}, "right": {"_type": "Name", "_fields": {"id": "batch_size", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "mu_v", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 10.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sqrt", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 15.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sqrt", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "sigma_v", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 200000}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "n", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "n", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sample", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "samples", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Name", "_fields": {"id": "samples", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "sample_values", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_shape", "value": {"_type": "Name", "_fields": {"id": "samples", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 200000}}, {"_type": "Name", "_fields": {"id": "batch_size", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mean", "value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}]}}, "value": {"_type": "Name", "_fields": {"id": "sample_values", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "mu_v", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "rtol", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.01}}}}, {"_type": "keyword", "_fields": {"arg": "atol", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}}}]}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "var", "value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}]}}, "value": {"_type": "Name", "_fields": {"id": "sample_values", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}, {"_type": "BinOp", "_fields": {"op": {"_type": "Div", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Pow", "_fields": {}}, "left": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "sigma_v", "ctx": {"_type": "Load", "_fields": {}}}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": 2}}}}, "right": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "right": {"_type": "BinOp", "_fields": {"op": {"_type": "Sub", "_fields": {}}, "left": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Load", "_fields": {}}}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": 2}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "rtol", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.1}}}}, {"_type": "keyword", "_fields": {"arg": "atol", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}}}]}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "mu_v", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "sigma_v", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}]}}, "value": {"_type": "Name", "_fields": {"id": "sample_values", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_checkKLApprox", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mean", "value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}]}}, "value": {"_type": "Name", "_fields": {"id": "sample_values", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}, "value": {"_type": "Name", "_fields": {"id": "mu_v", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "rtol", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.01}}}}, {"_type": "keyword", "_fields": {"arg": "atol", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}}}]}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "var", "value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}]}}, "value": {"_type": "Name", "_fields": {"id": "sample_values", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}, {"_type": "BinOp", "_fields": {"op": {"_type": "Div", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Pow", "_fields": {}}, "left": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}, "value": {"_type": "Name", "_fields": {"id": "sigma_v", "ctx": {"_type": "Load", "_fields": {}}}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": 2}}}}, "right": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}, "value": {"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "right": {"_type": "BinOp", "_fields": {"op": {"_type": "Sub", "_fields": {}}, "left": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}, "value": {"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Load", "_fields": {}}}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": 2}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "rtol", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.1}}}}, {"_type": "keyword", "_fields": {"arg": "atol", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}}}]}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "df_v", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "mu_v", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "sigma_v", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}]}}, "value": {"_type": "Name", "_fields": {"id": "sample_values", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_checkKLApprox", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "name": "testStudentSampleMultiDimensional", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def testStudentSampleMultiDimensional(self): with self.test_session(): batch_size = 7 df = tf.constant([[3.0, 7.0]] * batch_size) mu = tf.constant([[3.0, -3.0]] * batch_size) sigma = tf.constant([[math.sqrt(10.0), math.sqrt(15.0)]] * batch_size) df_v = [3.0, 7.0] mu_v = [3.0, -3.0] sigma_v = [np.sqrt(10.0), np.sqrt(15.0)] n = tf.constant(200000) student = tf.contrib.distributions.StudentT(df=df, mu=mu, sigma=sigma) samples = student.sample(n) sample_values = samples.eval() self.assertEqual(samples.get_shape(), (200000, batch_size, 2)) self.assertAllClose( sample_values[:, 0, 0].mean(), mu_v[0], rtol=1e-2, atol=0) self.assertAllClose(sample_values[:, 0, 0].var(), sigma_v[0]**2 * df_v[0] / (df_v[0] - 2), rtol=1e-1, atol=0) self._checkKLApprox(df_v[0], mu_v[0], sigma_v[0], sample_values[:, 0, 0]) self.assertAllClose( sample_values[:, 0, 1].mean(), mu_v[1], rtol=1e-2, atol=0) self.assertAllClose(sample_values[:, 0, 1].var(), sigma_v[1]**2 * df_v[1] / (df_v[1] - 2), rtol=1e-1, atol=0) self._checkKLApprox(df_v[0], mu_v[0], sigma_v[0], sample_values[:, 0, 1])
14,460
[ -0.03280474990606308, -0.02285083569586277, 0.019855506718158722, 0.01641545444726944, -0.021163510158658028, -0.03453131392598152, -0.0036133620887994766, -0.018861422315239906, -0.017370298504829407, 0.06540022045373917, -0.0009720107773318887, -0.03201994672417641, -0.03581316024065018, ...
9
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "df", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "mu", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "sigma", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "samples", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "size", "value": {"_type": "Name", "_fields": {"id": "samples", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "n", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 137}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "seed", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "random", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "rvs", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "t", "value": {"_type": "Name", "_fields": {"id": "stats", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "loc", "value": {"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "scale", "value": {"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "size", "value": {"_type": "Name", "_fields": {"id": "n", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "sample_scipy", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.99}}, "targets": [{"_type": "Name", "_fields": {"id": "covg", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "covg", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "interval", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "t", "value": {"_type": "Name", "_fields": {"id": "stats", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "loc", "value": {"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "scale", "value": {"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "r", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": 100}}, "targets": [{"_type": "Name", "_fields": {"id": "bins", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "samples", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "histogram", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "bins", "value": {"_type": "Name", "_fields": {"id": "bins", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "range", "value": {"_type": "Name", "_fields": {"id": "r", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "hist", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "_", "ctx": {"_type": "Store", "_fields": {}}}}]}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "sample_scipy", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "histogram", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "bins", "value": {"_type": "Name", "_fields": {"id": "bins", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "range", "value": {"_type": "Name", "_fields": {"id": "r", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "hist_scipy", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "_", "ctx": {"_type": "Store", "_fields": {}}}}]}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sum", "value": {"_type": "Name", "_fields": {"id": "hist", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "n", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "BinOp", "_fields": {"op": {"_type": "Sub", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "covg", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": 0.01}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertGreater", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sum", "value": {"_type": "Name", "_fields": {"id": "hist_scipy", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "n", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "BinOp", "_fields": {"op": {"_type": "Sub", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "covg", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": 0.01}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertGreater", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "hist", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}, "targets": [{"_type": "Name", "_fields": {"id": "hist_min1", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Div", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "hist_min1", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sum", "value": {"_type": "Name", "_fields": {"id": "hist_min1", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "hist_norm", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "hist_scipy", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}, "targets": [{"_type": "Name", "_fields": {"id": "hist_scipy_min1", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Div", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "hist_scipy_min1", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sum", "value": {"_type": "Name", "_fields": {"id": "hist_scipy_min1", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "hist_scipy_norm", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Div", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "hist_scipy_norm", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "Name", "_fields": {"id": "hist_norm", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "log", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "right": {"_type": "Name", "_fields": {"id": "hist_scipy_norm", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sum", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "kl_appx", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "kl_appx", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertLess", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "name": "_checkKLApprox", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def _checkKLApprox(self, df, mu, sigma, samples): n = samples.size np.random.seed(137) sample_scipy = stats.t.rvs(df, loc=mu, scale=sigma, size=n) covg = 0.99 r = stats.t.interval(covg, df, loc=mu, scale=sigma) bins = 100 hist, _ = np.histogram(samples, bins=bins, range=r) hist_scipy, _ = np.histogram(sample_scipy, bins=bins, range=r) self.assertGreater(hist.sum(), n * (covg - .01)) self.assertGreater(hist_scipy.sum(), n * (covg - .01)) hist_min1 = hist + 1. # put at least one item in each bucket hist_norm = hist_min1 / hist_min1.sum() hist_scipy_min1 = hist_scipy + 1. # put at least one item in each bucket hist_scipy_norm = hist_scipy_min1 / hist_scipy_min1.sum() kl_appx = np.sum(np.log(hist_scipy_norm / hist_norm) * hist_scipy_norm) self.assertLess(kl_appx, 1)
14,461
[ 0.005416949279606342, -0.03468829765915871, 0.029559385031461716, -0.015448681078851223, -0.005500572733581066, 0.015523012727499008, 0.02355087548494339, 0.0026960859540849924, 0.02166779711842537, 0.029931044206023216, -0.002208281774073839, 0.007947336882352829, -0.019202450290322304, 0...
11
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "student", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_shape", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mean", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_shape", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "variance", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_shape", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "entropy", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_shape", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "log_pdf", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_shape", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "pdf", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_shape", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 37}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sample", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 37}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "name": "_check", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}]}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}]}}], "func": {"_type": "Name", "_fields": {"id": "_check", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}]}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}]}}], "func": {"_type": "Name", "_fields": {"id": "_check", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}]}}}}]}}], "func": {"_type": "Name", "_fields": {"id": "_check", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}], "name": "testBroadcastingParams", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def testBroadcastingParams(self): def _check(student): self.assertEqual(student.mean().get_shape(), (3,)) self.assertEqual(student.variance().get_shape(), (3,)) self.assertEqual(student.entropy().get_shape(), (3,)) self.assertEqual(student.log_pdf(2.).get_shape(), (3,)) self.assertEqual(student.pdf(2.).get_shape(), (3,)) self.assertEqual(student.sample(37).get_shape(), (37, 3,)) _check(tf.contrib.distributions.StudentT(df=[2., 3., 4.,], mu=2., sigma=1.)) _check(tf.contrib.distributions.StudentT(df=7., mu=[2., 3., 4.,], sigma=1.)) _check(tf.contrib.distributions.StudentT(df=7., mu=3., sigma=[2., 3., 4.,]))
14,462
[ -0.015769001096487045, -0.03633834421634674, 0.0407407321035862, -0.0066781966015696526, -0.02223578281700611, -0.02666304260492325, 0.0003983444767072797, -0.005627344362437725, 0.027682803571224213, 0.041586387902498245, 0.020768320187926292, 0.034597285091876984, -0.023802734911441803, ...
10
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.3}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.4}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 5.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}]}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}]}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mean", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "mean", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.3}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.4}}]}}, {"_type": "Name", "_fields": {"id": "mean", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "name": "testMeanAllowNanStatsIsFalseWorksWhenAllBatchMembersAreDefined", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def testMeanAllowNanStatsIsFalseWorksWhenAllBatchMembersAreDefined(self): with self.test_session(): mu = [1., 3.3, 4.4] student = tf.contrib.distributions.StudentT( df=[3., 5., 7.], mu=mu, sigma=[3., 2., 1.]) mean = student.mean().eval() self.assertAllClose([1., 3.3, 4.4], mean)
14,463
[ -0.0026265406049788, -0.03845280036330223, 0.03832963481545448, -0.0059766885824501514, 0.006786512676626444, 0.025446344166994095, 0.023771269246935844, -0.015161882154643536, -0.009028156287968159, 0.03308270871639252, 0.0061768353916704655, -0.002337097655981779, 0.018253378570079803, 0...
11
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "student", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "arg", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "shape", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_shape", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "arg", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "log_pdf", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}, {"_type": "Name", "_fields": {"id": "shape", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_shape", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "arg", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "pdf", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}, {"_type": "Name", "_fields": {"id": "shape", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "name": "_assert_shape", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "student", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Name", "_fields": {"id": "_assert_shape", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "array", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "dtype", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "float32", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Name", "_fields": {"id": "_assert_shape", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "array", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Name", "_fields": {"id": "_assert_shape", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "T", "value": {"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Name", "_fields": {"id": "_assert_shape", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}], "name": "_check", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}]}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}]}}], "func": {"_type": "Name", "_fields": {"id": "_check", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}]}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}]}}], "func": {"_type": "Name", "_fields": {"id": "_check", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}]}}}}]}}], "func": {"_type": "Name", "_fields": {"id": "_check", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "student", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Name", "_fields": {"id": "_assert_shape", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "array", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "dtype", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "float32", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Name", "_fields": {"id": "_assert_shape", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "array", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Name", "_fields": {"id": "_assert_shape", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "T", "value": {"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Name", "_fields": {"id": "_assert_shape", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}], "name": "_check2d", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}]}}]}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}]}}], "func": {"_type": "Name", "_fields": {"id": "_check2d", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}]}}]}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}]}}], "func": {"_type": "Name", "_fields": {"id": "_check2d", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}]}}]}}}}]}}], "func": {"_type": "Name", "_fields": {"id": "_check2d", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "student", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}]}}], "func": {"_type": "Name", "_fields": {"id": "_assert_shape", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "array", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "dtype", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "float32", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Name", "_fields": {"id": "_assert_shape", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "array", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Name", "_fields": {"id": "_assert_shape", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "T", "value": {"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}]}}], "func": {"_type": "Name", "_fields": {"id": "_assert_shape", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}], "name": "_check2d_rows", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}]}}, {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}]}}, {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}]}}]}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}]}}], "func": {"_type": "Name", "_fields": {"id": "_check2d_rows", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}]}}, {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}]}}, {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}]}}]}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}]}}], "func": {"_type": "Name", "_fields": {"id": "_check2d_rows", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}]}}, {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}]}}, {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}]}}]}}}}]}}], "func": {"_type": "Name", "_fields": {"id": "_check2d_rows", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}], "name": "testBroadcastingPdfArgs", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def testBroadcastingPdfArgs(self): def _assert_shape(student, arg, shape): self.assertEqual(student.log_pdf(arg).get_shape(), shape) self.assertEqual(student.pdf(arg).get_shape(), shape) def _check(student): _assert_shape(student, 2., (3,)) xs = np.array([2., 3., 4.], dtype=np.float32) _assert_shape(student, xs, (3,)) xs = np.array([xs]) _assert_shape(student, xs, (1, 3)) xs = xs.T _assert_shape(student, xs, (3, 3)) _check(tf.contrib.distributions.StudentT(df=[2., 3., 4.,], mu=2., sigma=1.)) _check(tf.contrib.distributions.StudentT(df=7., mu=[2., 3., 4.,], sigma=1.)) _check(tf.contrib.distributions.StudentT(df=7., mu=3., sigma=[2., 3., 4.,])) def _check2d(student): _assert_shape(student, 2., (1, 3)) xs = np.array([2., 3., 4.], dtype=np.float32) _assert_shape(student, xs, (1, 3)) xs = np.array([xs]) _assert_shape(student, xs, (1, 3)) xs = xs.T _assert_shape(student, xs, (3, 3)) _check2d(tf.contrib.distributions.StudentT( df=[[2., 3., 4.,]], mu=2., sigma=1.)) _check2d(tf.contrib.distributions.StudentT( df=7., mu=[[2., 3., 4.,]], sigma=1.)) _check2d(tf.contrib.distributions.StudentT( df=7., mu=3., sigma=[[2., 3., 4.,]])) def _check2d_rows(student): _assert_shape(student, 2., (3, 1)) xs = np.array([2., 3., 4.], dtype=np.float32) # (3,) _assert_shape(student, xs, (3, 3)) xs = np.array([xs]) # (1,3) _assert_shape(student, xs, (3, 3)) xs = xs.T # (3,1) _assert_shape(student, xs, (3, 1)) _check2d_rows(tf.contrib.distributions.StudentT( df=[[2.], [3.], [4.]], mu=2., sigma=1.)) _check2d_rows(tf.contrib.distributions.StudentT( df=7., mu=[[2.], [3.], [4.]], sigma=1.)) _check2d_rows(tf.contrib.distributions.StudentT( df=7., mu=3., sigma=[[2.], [3.], [4.]]))
14,464
[ -0.01796661876142025, -0.03261745721101761, 0.022694677114486694, -0.002675650641322136, -0.000430207175668329, -0.019035037606954575, -0.0004812487168237567, 0.006100422237068415, 0.029719218611717224, 0.03016132302582264, 0.012268388643860817, 0.014957854524254799, -0.028736764565110207, ...
11
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.3}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.4}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 0.5}}, {"_type": "Constant", "_fields": {"kind": null, "value": 5.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}]}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}]}}}}, {"_type": "keyword", "_fields": {"arg": "allow_nan_stats", "value": {"_type": "Constant", "_fields": {"kind": null, "value": false}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "With", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mean", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "x < y"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertRaisesOpError", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "name": "testMeanAllowNanStatsIsFalseRaisesWhenBatchMemberIsUndefined", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def testMeanAllowNanStatsIsFalseRaisesWhenBatchMemberIsUndefined(self): with self.test_session(): mu = [1., 3.3, 4.4] student = tf.contrib.distributions.StudentT( df=[0.5, 5., 7.], mu=mu, sigma=[3., 2., 1.], allow_nan_stats=False) with self.assertRaisesOpError("x < y"): student.mean().eval()
14,465
[ -0.012088065035641193, -0.027073467150330544, 0.02619476616382599, -0.0017247460782527924, -0.03628794476389885, -0.035219255834817886, -0.010817511938512325, 0.007296774070709944, 0.04025397077202797, 0.04229635372757912, 0.02392677031457424, 0.022240614518523216, -0.03569422662258148, 0....
10
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 2}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.3}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.4}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 0.5}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 5.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}]}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 5.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}]}}}}, {"_type": "keyword", "_fields": {"arg": "allow_nan_stats", "value": {"_type": "Constant", "_fields": {"kind": null, "value": true}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mean", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "mean", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "nan", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "nan", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.3}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.4}}]}}, {"_type": "Name", "_fields": {"id": "mean", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "name": "testMeanAllowNanStatsIsTrueReturnsNaNForUndefinedBatchMembers", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def testMeanAllowNanStatsIsTrueReturnsNaNForUndefinedBatchMembers(self): with self.test_session(): mu = [-2, 0., 1., 3.3, 4.4] student = tf.contrib.distributions.StudentT( df=[0.5, 1., 3., 5., 7.], mu=mu, sigma=[5., 4., 3., 2., 1.], allow_nan_stats=True) mean = student.mean().eval() self.assertAllClose([np.nan, np.nan, 1., 3.3, 4.4], mean)
14,466
[ -0.030371902510523796, -0.01858164556324482, 0.006128661334514618, 0.0017136266687884927, -0.03860235959291458, -0.029765980318188667, -0.022759992629289627, -0.03327528387308121, 0.04504029452800751, 0.056098394095897675, 0.05619938299059868, 0.006936558987945318, -0.03840038552880287, 0....
10
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 0.5}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1.5}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 5.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 2}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.3}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.4}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 5.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "allow_nan_stats", "value": {"_type": "Constant", "_fields": {"kind": null, "value": true}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "variance", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "var", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "var", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "isnan", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertTrue", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "inf", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "var", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "ListComp", "_fields": {"elt": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "d", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "var", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "t", "value": {"_type": "Name", "_fields": {"id": "stats", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "loc", "value": {"_type": "Name", "_fields": {"id": "m", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "scale", "value": {"_type": "Name", "_fields": {"id": "s", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "generators": [{"_type": "comprehension", "_fields": {"ifs": [], "iter": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "zip", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "target": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "d", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "m", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "s", "ctx": {"_type": "Store", "_fields": {}}}}]}}, "is_async": 0}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "expected_var", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "expected_var", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "var", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "name": "testVarianceAllowNanStatsTrueReturnsNaNforUndefinedBatchMembers", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def testVarianceAllowNanStatsTrueReturnsNaNforUndefinedBatchMembers(self): with self.test_session(): # df = 0.5 ==> undefined mean ==> undefined variance. # df = 1.5 ==> infinite variance. df = [0.5, 1.5, 3., 5., 7.] mu = [-2, 0., 1., 3.3, 4.4] sigma = [5., 4., 3., 2., 1.] student = tf.contrib.distributions.StudentT( df=df, mu=mu, sigma=sigma, allow_nan_stats=True) var = student.variance().eval() ## scipy uses inf for variance when the mean is undefined. When mean is # undefined we say variance is undefined as well. So test the first # member of var, making sure it is NaN, then replace with inf and compare # to scipy. self.assertTrue(np.isnan(var[0])) var[0] = np.inf expected_var = [ stats.t.var(d, loc=m, scale=s) for (d, m, s) in zip(df, mu, sigma)] self.assertAllClose(expected_var, var)
14,467
[ -0.026561200618743896, -0.024296589195728302, 0.02485954388976097, -0.00008321365748997778, -0.03956032544374466, -0.03838323801755905, -0.037206150591373444, -0.02633090130984783, 0.03751321882009506, 0.04424307867884636, 0.052303560078144073, 0.02735445462167263, -0.02613898552954197, 0....
10
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 1.5}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 5.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 0.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.3}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.4}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "variance", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "var", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "ListComp", "_fields": {"elt": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "d", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "var", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "t", "value": {"_type": "Name", "_fields": {"id": "stats", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "loc", "value": {"_type": "Name", "_fields": {"id": "m", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "scale", "value": {"_type": "Name", "_fields": {"id": "s", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "generators": [{"_type": "comprehension", "_fields": {"ifs": [], "iter": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "zip", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "target": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "d", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "m", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "s", "ctx": {"_type": "Store", "_fields": {}}}}]}}, "is_async": 0}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "expected_var", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "expected_var", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "var", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "name": "testVarianceAllowNanStatsFalseGivesCorrectValueForDefinedBatchMembers", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def testVarianceAllowNanStatsFalseGivesCorrectValueForDefinedBatchMembers( self): with self.test_session(): # df = 1.5 ==> infinite variance. df = [1.5, 3., 5., 7.] mu = [0., 1., 3.3, 4.4] sigma = [4., 3., 2., 1.] student = tf.contrib.distributions.StudentT( df=df, mu=mu, sigma=sigma) var = student.variance().eval() expected_var = [ stats.t.var(d, loc=m, scale=s) for (d, m, s) in zip(df, mu, sigma)] self.assertAllClose(expected_var, var)
14,468
[ 0.005684670526534319, -0.036041583865880966, 0.026257764548063278, -0.009113519452512264, -0.03127213194966316, 0.006896369159221649, 0.013264231383800507, 0.01423101220279932, 0.022455092519521713, 0.03271586075425148, 0.008050060831010342, 0.014759519137442112, -0.025252312421798706, 0.0...
10
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3.5}}, {"_type": "Constant", "_fields": {"kind": null, "value": 5.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 5.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 2.2}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 5.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "std", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "std", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "AugAssign", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "len", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "target": {"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Store", "_fields": {}}}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "ListComp", "_fields": {"elt": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "d", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "std", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "t", "value": {"_type": "Name", "_fields": {"id": "stats", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "loc", "value": {"_type": "Name", "_fields": {"id": "m", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "scale", "value": {"_type": "Name", "_fields": {"id": "s", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "generators": [{"_type": "comprehension", "_fields": {"ifs": [], "iter": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "zip", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "target": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "d", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "m", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "s", "ctx": {"_type": "Store", "_fields": {}}}}]}}, "is_async": 0}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "expected_std", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "expected_std", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "std", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "name": "testStd", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def testStd(self): with self.test_session(): # Defined for all batch members. df = [3.5, 5., 3., 5., 7.] mu = [-2.2] sigma = [5., 4., 3., 2., 1.] student = tf.contrib.distributions.StudentT(df=df, mu=mu, sigma=sigma) # Test broadcast of mu across shape of df/sigma std = student.std().eval() mu *= len(df) expected_std = [ stats.t.std(d, loc=m, scale=s) for (d, m, s) in zip(df, mu, sigma)] self.assertAllClose(expected_std, std)
14,469
[ -0.03183525428175926, -0.014722179621458054, 0.02118018828332424, -0.0017249509692192078, -0.010629076510667801, -0.011642606928944588, -0.01192847453057766, -0.022206712514162064, 0.03859212249517441, 0.03895595297217369, 0.04017738997936249, -0.0062338621355593204, -0.011785540729761124, ...
11
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.0}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}, {"_type": "keyword", "_fields": {"arg": "allow_nan_stats", "value": {"_type": "Constant", "_fields": {"kind": null, "value": false}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "With", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "variance", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "x < y"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertRaisesOpError", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}, {"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.5}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.0}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}, {"_type": "keyword", "_fields": {"arg": "allow_nan_stats", "value": {"_type": "Constant", "_fields": {"kind": null, "value": false}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "With", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "variance", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "x < y"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertRaisesOpError", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "name": "testVarianceAllowNanStatsFalseRaisesForUndefinedBatchMembers", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def testVarianceAllowNanStatsFalseRaisesForUndefinedBatchMembers(self): with self.test_session(): # df <= 1 ==> variance not defined student = tf.contrib.distributions.StudentT( df=1.0, mu=0.0, sigma=1.0, allow_nan_stats=False) with self.assertRaisesOpError("x < y"): student.variance().eval() with self.test_session(): # df <= 1 ==> variance not defined student = tf.contrib.distributions.StudentT( df=0.5, mu=0.0, sigma=1.0, allow_nan_stats=False) with self.assertRaisesOpError("x < y"): student.variance().eval()
14,470
[ 0.009038346819579601, -0.04930880293250084, 0.035409193485975266, -0.022757908329367638, 0.0001144984780694358, -0.02385019324719906, 0.010442711412906647, 0.02998378500342369, 0.03401683270931244, 0.014283709228038788, 0.02791924960911274, -0.005029305815696716, -0.02585471421480179, 0.03...
10
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "pi", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": 20000}}, "targets": [{"_type": "Name", "_fields": {"id": "num", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "num", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sample", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "samples", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "samples", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "pdf", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "pdfs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mean", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "mean", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mean", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "pdf", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "mean_pdf", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "samples", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "pdfs", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mean", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Name", "_fields": {"id": "mean_pdf", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "run", "value": {"_type": "Name", "_fields": {"id": "sess", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "sample_vals", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "pdf_vals", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "mean_val", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "mean_pdf_val", "ctx": {"_type": "Store", "_fields": {}}}}]}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_shape", "value": {"_type": "Name", "_fields": {"id": "samples", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "num", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_shape", "value": {"_type": "Name", "_fields": {"id": "pdfs", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "num", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_shape", "value": {"_type": "Name", "_fields": {"id": "mean", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "pi", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "sample_vals", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mean", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertNear", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "err", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.02}}}}]}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "pi", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Name", "_fields": {"id": "mean_val", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertNear", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "err", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.000001}}}}]}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "pi", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "pdf", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "t", "value": {"_type": "Name", "_fields": {"id": "stats", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "loc", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "pi", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}}}]}}, {"_type": "Name", "_fields": {"id": "mean_pdf_val", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertNear", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "err", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.000001}}}}]}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "sample_vals", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "pdf_vals", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_assertIntegral", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": {"_type": "Name", "_fields": {"id": "sess", "ctx": {"_type": "Store", "_fields": {}}}}}}], "type_comment": null}}], "name": "testPdfOfSample", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def testPdfOfSample(self): with self.test_session() as sess: student = tf.contrib.distributions.StudentT(df=3., mu=np.pi, sigma=1.) num = 20000 samples = student.sample(num) pdfs = student.pdf(samples) mean = student.mean() mean_pdf = student.pdf(student.mean()) sample_vals, pdf_vals, mean_val, mean_pdf_val = sess.run( [samples, pdfs, student.mean(), mean_pdf]) self.assertEqual(samples.get_shape(), (num,)) self.assertEqual(pdfs.get_shape(), (num,)) self.assertEqual(mean.get_shape(), ()) self.assertNear(np.pi, np.mean(sample_vals), err=0.02) self.assertNear(np.pi, mean_val, err=1e-6) self.assertNear(stats.t.pdf(np.pi, 3., loc=np.pi), mean_pdf_val, err=1e-6) # Verify integral over sample*pdf ~= 1. self._assertIntegral(sample_vals, pdf_vals)
14,471
[ 0.006335299927741289, -0.014092424884438515, 0.013438133522868156, -0.019100269302725792, -0.0025888539385050535, 0.02271145209670067, 0.046605661511421204, 0.024951141327619553, 0.046152692288160324, 0.04637917876243591, 0.011110367253422737, 0.033444344997406006, -0.005353863351047039, 0...
10
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 0.5}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}]}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 5.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}]}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mode", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "mode", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}]}}, {"_type": "Name", "_fields": {"id": "mode", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "name": "testMode", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def testMode(self): with self.test_session(): student = tf.contrib.distributions.StudentT( df=[0.5, 1., 3], mu=[-1, 0., 1], sigma=[5., 4., 3.]) # Test broadcast of mu across shape of df/sigma mode = student.mode().eval() self.assertAllClose([-1., 0, 1], mode)
14,472
[ 0.019007565453648567, -0.03940996527671814, 0.022317340597510338, 0.0016120378859341145, -0.050308581441640854, -0.013203638605773449, 0.015035836026072502, -0.012222526594996452, 0.016466131433844566, 0.04527299478650093, 0.025934452190995216, -0.012127961963415146, 0.0015573673881590366, ...
9
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "sample_vals", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "pdf_vals", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "err", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [{"_type": "Constant", "_fields": {"kind": null, "value": 0.001}}], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "sample_vals", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "pdf_vals", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "zip", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "s_p", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "BinOp", "_fields": {"op": {"_type": "Sub", "_fields": {}}, "left": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "min", "value": {"_type": "Name", "_fields": {"id": "sample_vals", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": 1000}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "prev", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "targets": [{"_type": "Name", "_fields": {"id": "total", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "For", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Div", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}, "value": {"_type": "Name", "_fields": {"id": "k", "ctx": {"_type": "Load", "_fields": {}}}}}}, "right": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}, "value": {"_type": "Name", "_fields": {"id": "prev", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": 2}}}}, "targets": [{"_type": "Name", "_fields": {"id": "pair_pdf", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "AugAssign", "_fields": {"op": {"_type": "Add", "_fields": {}}, "value": {"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Sub", "_fields": {}}, "left": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "k", "ctx": {"_type": "Load", "_fields": {}}}}}}, "right": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "prev", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "right": {"_type": "Name", "_fields": {"id": "pair_pdf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "target": {"_type": "Name", "_fields": {"id": "total", "ctx": {"_type": "Store", "_fields": {}}}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Name", "_fields": {"id": "k", "ctx": {"_type": "Load", "_fields": {}}}}, "targets": [{"_type": "Name", "_fields": {"id": "prev", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}], "iter": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "s_p", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "sorted", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "key", "value": {"_type": "Lambda", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "x", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "x", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}]}}, "orelse": [], "target": {"_type": "Name", "_fields": {"id": "k", "ctx": {"_type": "Store", "_fields": {}}}}, "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}, {"_type": "Name", "_fields": {"id": "total", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertNear", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "err", "value": {"_type": "Name", "_fields": {"id": "err", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}}}], "name": "_assertIntegral", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def _assertIntegral(self, sample_vals, pdf_vals, err=1e-3): s_p = zip(sample_vals, pdf_vals) prev = (sample_vals.min() - 1000, 0) total = 0 for k in sorted(s_p, key=lambda x: x[0]): pair_pdf = (k[1] + prev[1]) / 2 total += (k[0] - prev[0]) * pair_pdf prev = k self.assertNear(1., total, err=err)
14,473
[ 0.014200108125805855, -0.040882471948862076, 0.06555037200450897, -0.028523802757263184, -0.00905272364616394, -0.012630557641386986, 0.005579938180744648, 0.008230872452259064, -0.00019165589765179902, 0.012309232726693153, 0.014447282068431377, -0.013470946811139584, -0.00407836027443409, ...
10
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 11.0}}]}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 5.0}}]}}, {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 6.0}}]}}]}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": 50000}}, "targets": [{"_type": "Name", "_fields": {"id": "num", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "num", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sample", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "samples", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "samples", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "pdf", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "pdfs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "samples", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "pdfs", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "run", "value": {"_type": "Name", "_fields": {"id": "sess", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "sample_vals", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "pdf_vals", "ctx": {"_type": "Store", "_fields": {}}}}]}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_shape", "value": {"_type": "Name", "_fields": {"id": "samples", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "num", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_shape", "value": {"_type": "Name", "_fields": {"id": "pdfs", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "num", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 5.0}}, {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, {"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}]}}, "value": {"_type": "Name", "_fields": {"id": "sample_vals", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mean", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertNear", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "err", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.03}}}}]}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 6.0}}, {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}, {"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}]}}, "value": {"_type": "Name", "_fields": {"id": "sample_vals", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mean", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertNear", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "err", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.03}}}}]}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 7.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "var", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "t", "value": {"_type": "Name", "_fields": {"id": "stats", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "loc", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.0}}}}, {"_type": "keyword", "_fields": {"arg": "scale", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}}}]}}, {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}]}}, "value": {"_type": "Name", "_fields": {"id": "sample_vals", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "var", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertNear", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "err", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.3}}}}]}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 11.0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "var", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "t", "value": {"_type": "Name", "_fields": {"id": "stats", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "loc", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.0}}}}, {"_type": "keyword", "_fields": {"arg": "scale", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}}}]}}, {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}]}}, "value": {"_type": "Name", "_fields": {"id": "sample_vals", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "var", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertNear", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "err", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.3}}}}]}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}]}}, "value": {"_type": "Name", "_fields": {"id": "sample_vals", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}]}}, "value": {"_type": "Name", "_fields": {"id": "pdf_vals", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_assertIntegral", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "err", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.02}}}}]}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}]}}, "value": {"_type": "Name", "_fields": {"id": "sample_vals", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}]}}, "value": {"_type": "Name", "_fields": {"id": "pdf_vals", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_assertIntegral", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "err", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.02}}}}]}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}]}}, "value": {"_type": "Name", "_fields": {"id": "sample_vals", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}]}}, "value": {"_type": "Name", "_fields": {"id": "pdf_vals", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_assertIntegral", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "err", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.02}}}}]}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}]}}, "value": {"_type": "Name", "_fields": {"id": "sample_vals", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}]}}, "value": {"_type": "Name", "_fields": {"id": "pdf_vals", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_assertIntegral", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "err", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.02}}}}]}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": {"_type": "Name", "_fields": {"id": "sess", "ctx": {"_type": "Store", "_fields": {}}}}}}], "type_comment": null}}], "name": "testPdfOfSampleMultiDims", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def testPdfOfSampleMultiDims(self): with self.test_session() as sess: student = tf.contrib.distributions.StudentT(df=[7., 11.], mu=[[5.], [6.]], sigma=3.) num = 50000 samples = student.sample(num) pdfs = student.pdf(samples) sample_vals, pdf_vals = sess.run([samples, pdfs]) self.assertEqual(samples.get_shape(), (num, 2, 2)) self.assertEqual(pdfs.get_shape(), (num, 2, 2)) self.assertNear(5., np.mean(sample_vals[:, 0, :]), err=.03) self.assertNear(6., np.mean(sample_vals[:, 1, :]), err=.03) self.assertNear(stats.t.var(7., loc=0., scale=3.), # loc d.n. effect var np.var(sample_vals[:, :, 0]), err=.3) self.assertNear(stats.t.var(11., loc=0., scale=3.), # loc d.n. effect var np.var(sample_vals[:, :, 1]), err=.3) self._assertIntegral(sample_vals[:, 0, 0], pdf_vals[:, 0, 0], err=0.02) self._assertIntegral(sample_vals[:, 0, 1], pdf_vals[:, 0, 1], err=0.02) self._assertIntegral(sample_vals[:, 1, 0], pdf_vals[:, 1, 0], err=0.02) self._assertIntegral(sample_vals[:, 1, 1], pdf_vals[:, 1, 1], err=0.02)
14,474
[ 0.014307864010334015, -0.004905919544398785, 0.030229687690734863, -0.0186245609074831, 0.007448543794453144, 0.04503710940480232, 0.008691035211086273, 0.010676459409296513, 0.02666873298585415, 0.0071411230601370335, 0.017471734434366226, -0.0212120171636343, -0.05233834683895111, 0.0104...
11
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2}}, {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 5.0}}}}]}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.0}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}, {"_type": "keyword", "_fields": {"arg": "validate_args", "value": {"_type": "Constant", "_fields": {"kind": null, "value": true}}}}, {"_type": "keyword", "_fields": {"arg": "name", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "S"}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "With", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mean", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "Condition x > 0 did not hold"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertRaisesOpError", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "name": "testNegativeDofFails", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def testNegativeDofFails(self): with self.test_session(): student = tf.contrib.distributions.StudentT(df=[2, -5.], mu=0., sigma=1., validate_args=True, name="S") with self.assertRaisesOpError(r"Condition x > 0 did not hold"): student.mean().eval()
14,475
[ 0.017313439399003983, 0.007568264380097389, 0.023576829582452774, -0.032819151878356934, 0.0007582586258649826, 0.025410018861293793, 0.026224767789244652, -0.006931740790605545, 0.0330992229282856, 0.024824416264891624, 0.007625551428645849, -0.024493424221873283, -0.057338036596775055, 0...
11
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentT", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 5.0}}]}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Constant", "_fields": {"kind": null, "value": 0.0}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}]}}, {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}}}]}}]}}}}, {"_type": "keyword", "_fields": {"arg": "validate_args", "value": {"_type": "Constant", "_fields": {"kind": null, "value": true}}}}, {"_type": "keyword", "_fields": {"arg": "name", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "S"}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "With", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mean", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "Condition x > 0 did not hold"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertRaisesOpError", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "name": "testNegativeScaleFails", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def testNegativeScaleFails(self): with self.test_session(): student = tf.contrib.distributions.StudentT(df=[5.], mu=0., sigma=[[3.], [-2.]], validate_args=True, name="S") with self.assertRaisesOpError(r"Condition x > 0 did not hold"): student.mean().eval()
14,476
[ 0.0035982185509055853, -0.01498156413435936, 0.042553890496492386, -0.0038595248479396105, 0.00017335949814878404, 0.0037183593958616257, 0.03882952407002449, 0.03133273497223854, 0.035081129521131516, 0.028881860896945, 0.011329282075166702, -0.0030290512368083, -0.05425560846924782, 0.02...
12
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 3.2}}}}, {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 4.6}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 4.2}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.4}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 6.4}}}}, {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 8.8}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "StudentTWithAbsDfSoftplusSigma", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "distributions", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "contrib", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "df", "value": {"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "mu", "value": {"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "keyword", "_fields": {"arg": "sigma", "value": {"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "df", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "abs", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "floor", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "keywords": []}}, {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "df", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Name", "_fields": {"id": "mu", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mu", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "sigma", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "softplus", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "nn", "value": {"_type": "Name", "_fields": {"id": "tf", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}, "keywords": []}}, {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sigma", "value": {"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_session", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "name": "testStudentTWithAbsDfSoftplusSigma", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def testStudentTWithAbsDfSoftplusSigma(self): with self.test_session(): df = tf.constant([-3.2, -4.6]) mu = tf.constant([-4.2, 3.4]) sigma = tf.constant([-6.4, -8.8]) student = tf.contrib.distributions.StudentTWithAbsDfSoftplusSigma( df=df, mu=mu, sigma=sigma) self.assertAllClose(tf.floor(tf.abs(df)).eval(), student.df.eval()) self.assertAllClose(mu.eval(), student.mu.eval()) self.assertAllClose(tf.nn.softplus(sigma).eval(), student.sigma.eval())
14,477
[ -0.013782980851829052, -0.0021976004354655743, 0.03883245214819908, 0.005517809651792049, 0.022232847288250923, 0.017996370792388916, 0.024726251140236855, -0.018758244812488556, 0.0030676943715661764, 0.05633245036005974, 0.019046831876039505, -0.010539247654378414, 0.0033129944931715727, ...
8
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "student", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Name", "_fields": {"id": "_assert_shape", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "array", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "dtype", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "float32", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Name", "_fields": {"id": "_assert_shape", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "array", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Name", "_fields": {"id": "_assert_shape", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "T", "value": {"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Name", "_fields": {"id": "_assert_shape", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}], "name": "_check", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def _check(student): _assert_shape(student, 2., (3,)) xs = np.array([2., 3., 4.], dtype=np.float32) _assert_shape(student, xs, (3,)) xs = np.array([xs]) _assert_shape(student, xs, (1, 3)) xs = xs.T _assert_shape(student, xs, (3, 3))
14,478
[ -0.016445467248558998, -0.008881678804755211, 0.04350164160132408, 0.009028111584484577, 0.01278466172516346, 0.0241725854575634, 0.02538909949362278, -0.02055683545768261, -0.006893579848110676, 0.06510603427886963, 0.023789608851075172, -0.012390420772135258, 0.010914834216237068, 0.0714...
8
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "student", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Name", "_fields": {"id": "_assert_shape", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "array", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "dtype", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "float32", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Name", "_fields": {"id": "_assert_shape", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "array", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Name", "_fields": {"id": "_assert_shape", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "T", "value": {"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Name", "_fields": {"id": "_assert_shape", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}], "name": "_check2d", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def _check2d(student): _assert_shape(student, 2., (1, 3)) xs = np.array([2., 3., 4.], dtype=np.float32) _assert_shape(student, xs, (1, 3)) xs = np.array([xs]) _assert_shape(student, xs, (1, 3)) xs = xs.T _assert_shape(student, xs, (3, 3))
14,479
[ -0.0233459435403347, -0.004134058021008968, 0.04003146290779114, -0.0005242932820692658, 0.020854026079177856, 0.009290146641433239, 0.029122142121195793, -0.03321026638150215, -0.02298995479941368, 0.060265377163887024, 0.0038182619027793407, -0.009204020723700523, 0.01361942384392023, 0....
8
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "student", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}]}}], "func": {"_type": "Name", "_fields": {"id": "_assert_shape", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "array", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "dtype", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "float32", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Name", "_fields": {"id": "_assert_shape", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "array", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3}}]}}], "func": {"_type": "Name", "_fields": {"id": "_assert_shape", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "T", "value": {"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "student", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "xs", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}]}}], "func": {"_type": "Name", "_fields": {"id": "_assert_shape", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}], "name": "_check2d_rows", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def _check2d_rows(student): _assert_shape(student, 2., (3, 1)) xs = np.array([2., 3., 4.], dtype=np.float32) # (3,) _assert_shape(student, xs, (3, 3)) xs = np.array([xs]) # (1,3) _assert_shape(student, xs, (3, 3)) xs = xs.T # (3,1) _assert_shape(student, xs, (3, 1))
14,480
[ 0.00044380276813171804, -0.016512010246515274, 0.00013820173626299948, 0.009790558367967606, 0.0017355731688439846, -0.04502863809466362, 0.05200490728020668, -0.007485898211598396, 0.004578175954520702, 0.04856207221746445, 0.009009125642478466, 0.019377263262867928, -0.009077075868844986, ...
11
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "color", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "text", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "If", "_fields": {"body": [{"_type": "Return", "_fields": {"value": {"_type": "Name", "_fields": {"id": "text", "ctx": {"_type": "Load", "_fields": {}}}}}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Lt", "_fields": {}}], "left": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "color", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "len", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}]}}, "orelse": []}}, {"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": ""}}, "targets": [{"_type": "Name", "_fields": {"id": "add", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "sub", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "If", "_fields": {"body": [{"_type": "AugAssign", "_fields": {"op": {"_type": "Add", "_fields": {}}, "value": {"_type": "Constant", "_fields": {"kind": null, "value": "\u001d"}}, "target": {"_type": "Name", "_fields": {"id": "add", "ctx": {"_type": "Store", "_fields": {}}}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "Constant", "_fields": {"kind": null, "value": "\u001d"}}, "right": {"_type": "Name", "_fields": {"id": "sub", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "sub", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "_"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "strip", "value": {"_type": "Name", "_fields": {"id": "color", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "color", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "In", "_fields": {}}], "left": {"_type": "Constant", "_fields": {"kind": null, "value": "_"}}, "comparators": [{"_type": "Name", "_fields": {"id": "color", "ctx": {"_type": "Load", "_fields": {}}}}]}}, "orelse": []}}, {"_type": "If", "_fields": {"body": [{"_type": "AugAssign", "_fields": {"op": {"_type": "Add", "_fields": {}}, "value": {"_type": "Constant", "_fields": {"kind": null, "value": "\u0002"}}, "target": {"_type": "Name", "_fields": {"id": "add", "ctx": {"_type": "Store", "_fields": {}}}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "Constant", "_fields": {"kind": null, "value": "\u0002"}}, "right": {"_type": "Name", "_fields": {"id": "sub", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "sub", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "*"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "strip", "value": {"_type": "Name", "_fields": {"id": "color", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "color", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "In", "_fields": {}}], "left": {"_type": "Constant", "_fields": {"kind": null, "value": "*"}}, "comparators": [{"_type": "Name", "_fields": {"id": "color", "ctx": {"_type": "Load", "_fields": {}}}}]}}, "orelse": []}}, {"_type": "If", "_fields": {"body": [{"_type": "AugAssign", "_fields": {"op": {"_type": "Add", "_fields": {}}, "value": {"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "Constant", "_fields": {"kind": null, "value": "\u0003"}}, "right": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 2}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "zfill", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Name", "_fields": {"id": "color", "ctx": {"_type": "Load", "_fields": {}}}}, "value": {"_type": "Name", "_fields": {"id": "IRC_COLOR_MAP", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Name", "_fields": {"id": "str", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, "keywords": []}}}}, "target": {"_type": "Name", "_fields": {"id": "add", "ctx": {"_type": "Store", "_fields": {}}}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "Constant", "_fields": {"kind": null, "value": "\u0003"}}, "right": {"_type": "Name", "_fields": {"id": "sub", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "sub", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Gt", "_fields": {}}], "left": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "color", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "len", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": 0}}]}}, "orelse": []}}, {"_type": "Return", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "add", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "Name", "_fields": {"id": "text", "ctx": {"_type": "Load", "_fields": {}}}}}}, "right": {"_type": "Name", "_fields": {"id": "sub", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Return", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "Constant", "_fields": {"kind": null, "value": "<"}}, "right": {"_type": "Name", "_fields": {"id": "add", "ctx": {"_type": "Load", "_fields": {}}}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": ">"}}}}, "right": {"_type": "Name", "_fields": {"id": "text", "ctx": {"_type": "Load", "_fields": {}}}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": "</"}}}}, "right": {"_type": "Name", "_fields": {"id": "sub", "ctx": {"_type": "Load", "_fields": {}}}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": ">"}}}}}}], "name": "ircformat", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def ircformat(color, text): if len(color) < 1: return text add = sub = '' if '_' in color: # italic add += '\x1D' sub = '\x1D' + sub color = color.strip('_') if '*' in color: # bold add += '\x02' sub = '\x02' + sub color = color.strip('*') # underline (\x1F) not supported # backgrounds (\x03FF,BB) not supported if len(color) > 0: # actual color - may have issues with ircformat("red", "blah")+"10" type stuff add += '\x03' + str(IRC_COLOR_MAP[color]).zfill(2) sub = '\x03' + sub return add + text + sub return '<'+add+'>'+text+'</'+sub+'>'
14,481
[ -0.029202822595834732, -0.00577325327321887, 0.02092869020998478, -0.02483275532722473, 0.009806763380765915, -0.005322784185409546, 0.02344510331749916, 0.05219227820634842, 0.06105668097734451, 0.032827287912368774, 0.021249713376164436, -0.01294451393187046, 0.03904065117239952, -0.0276...
9
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "service_plugin", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "service_plugin", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "__init__", "value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "IPsecVPNDriver", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "super", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "IPsecVpnDriverCallBack", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "callbacks", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "create_connection", "value": {"_type": "Name", "_fields": {"id": "rpc", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "new", "value": {"_type": "Constant", "_fields": {"kind": null, "value": true}}}}]}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "conn", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "IPSEC_DRIVER_TOPIC", "value": {"_type": "Name", "_fields": {"id": "topics", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "create_rpc_dispatcher", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "callbacks", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "create_consumer", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "conn", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "fanout", "value": {"_type": "Constant", "_fields": {"kind": null, "value": false}}}}]}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "consume_in_thread", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "conn", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "IPSEC_AGENT_TOPIC", "value": {"_type": "Name", "_fields": {"id": "topics", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Name", "_fields": {"id": "BASE_IPSEC_VERSION", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "IPsecVpnAgentApi", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "agent_rpc", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}], "name": "__init__", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def __init__(self, service_plugin): super(IPsecVPNDriver, self).__init__(service_plugin) self.callbacks = IPsecVpnDriverCallBack(self) self.conn = rpc.create_connection(new=True) self.conn.create_consumer( topics.IPSEC_DRIVER_TOPIC, self.callbacks.create_rpc_dispatcher(), fanout=False) self.conn.consume_in_thread() self.agent_rpc = IPsecVpnAgentApi( topics.IPSEC_AGENT_TOPIC, BASE_IPSEC_VERSION)
14,482
[ 0.010570394806563854, -0.007771166041493416, -0.017289694398641586, -0.06295104324817657, 0.009932377375662327, -0.06658371537923813, 0.04589126259088516, -0.01831282116472721, -0.0018924972973763943, 0.0187496617436409, 0.02202596701681614, 0.01262239646166563, -0.009892142377793789, 0.00...
11
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "tokensource", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "outfile", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "If", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "tokensource", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "outfile", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_format_unencoded_with_lineno", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Return", "_fields": {"value": null}}], "test": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "linenos", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "orelse": []}}, {"_type": "For", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "ttype", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "colorscheme", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "color", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "While", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}}}}}, "value": {"_type": "Name", "_fields": {"id": "ttype", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "ttype", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "ttype", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "colorscheme", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "color", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Is", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "color", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": null}}]}}, "orelse": []}}, {"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "darkbg", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "value": {"_type": "Name", "_fields": {"id": "color", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "color", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "\n"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "split", "value": {"_type": "Name", "_fields": {"id": "value", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "spl", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "For", "_fields": {"body": [{"_type": "If", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "color", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "line", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "ircformat", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "write", "value": {"_type": "Name", "_fields": {"id": "outfile", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "test": {"_type": "Name", "_fields": {"id": "line", "ctx": {"_type": "Load", "_fields": {}}}}, "orelse": []}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "\n"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "write", "value": {"_type": "Name", "_fields": {"id": "outfile", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "iter": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}}}}}, "value": {"_type": "Name", "_fields": {"id": "spl", "ctx": {"_type": "Load", "_fields": {}}}}}}, "orelse": [], "target": {"_type": "Name", "_fields": {"id": "line", "ctx": {"_type": "Store", "_fields": {}}}}, "type_comment": null}}, {"_type": "If", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "color", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}}}, "value": {"_type": "Name", "_fields": {"id": "spl", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Name", "_fields": {"id": "ircformat", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "write", "value": {"_type": "Name", "_fields": {"id": "outfile", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "test": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}}}, "value": {"_type": "Name", "_fields": {"id": "spl", "ctx": {"_type": "Load", "_fields": {}}}}}}, "orelse": []}}], "test": {"_type": "Name", "_fields": {"id": "color", "ctx": {"_type": "Load", "_fields": {}}}}, "orelse": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "value", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "write", "value": {"_type": "Name", "_fields": {"id": "outfile", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}]}}], "iter": {"_type": "Name", "_fields": {"id": "tokensource", "ctx": {"_type": "Load", "_fields": {}}}}, "orelse": [], "target": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "ttype", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "value", "ctx": {"_type": "Store", "_fields": {}}}}]}}, "type_comment": null}}], "name": "format_unencoded", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def format_unencoded(self, tokensource, outfile): if self.linenos: self._format_unencoded_with_lineno(tokensource, outfile) return for ttype, value in tokensource: color = self.colorscheme.get(ttype) while color is None: ttype = ttype[:-1] color = self.colorscheme.get(ttype) if color: color = color[self.darkbg] spl = value.split('\n') for line in spl[:-1]: if line: outfile.write(ircformat(color, line)) outfile.write('\n') if spl[-1]: outfile.write(ircformat(color, spl[-1])) else: outfile.write(value)
14,483
[ 0.031607434153556824, 0.006154275964945555, -0.006386512890458107, -0.07111091911792755, 0.01733648031949997, -0.052485525608062744, 0.038226183503866196, -0.015118617564439774, -0.01812608540058136, 0.026776906102895737, 0.0034603287931531668, 0.031932562589645386, -0.013202663511037827, ...
13
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "tokensource", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "outfile", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "outfile", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_write_lineno", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "For", "_fields": {"body": [{"_type": "If", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "outfile", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_write_lineno", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}}}}}, "value": {"_type": "Name", "_fields": {"id": "value", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "value", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}], "test": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "\n"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "endswith", "value": {"_type": "Name", "_fields": {"id": "value", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "orelse": []}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "ttype", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "colorscheme", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "color", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "While", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}}}}}, "value": {"_type": "Name", "_fields": {"id": "ttype", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "ttype", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "ttype", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "colorscheme", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "color", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Is", "_fields": {}}], "left": {"_type": "Name", "_fields": {"id": "color", "ctx": {"_type": "Load", "_fields": {}}}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": null}}]}}, "orelse": []}}, {"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "darkbg", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "value": {"_type": "Name", "_fields": {"id": "color", "ctx": {"_type": "Load", "_fields": {}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "color", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "\n"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "split", "value": {"_type": "Name", "_fields": {"id": "value", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "spl", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "For", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "outfile", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_write_lineno", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "If", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "color", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}}}}}, "value": {"_type": "Name", "_fields": {"id": "line", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Name", "_fields": {"id": "ircformat", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "write", "value": {"_type": "Name", "_fields": {"id": "outfile", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "test": {"_type": "Name", "_fields": {"id": "line", "ctx": {"_type": "Load", "_fields": {}}}}, "orelse": []}}], "iter": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}}}}}, "value": {"_type": "Name", "_fields": {"id": "spl", "ctx": {"_type": "Load", "_fields": {}}}}}}, "orelse": [], "target": {"_type": "Name", "_fields": {"id": "line", "ctx": {"_type": "Store", "_fields": {}}}}, "type_comment": null}}, {"_type": "If", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "color", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}}}, "value": {"_type": "Name", "_fields": {"id": "spl", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Name", "_fields": {"id": "ircformat", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "write", "value": {"_type": "Name", "_fields": {"id": "outfile", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "test": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}}}, "value": {"_type": "Name", "_fields": {"id": "spl", "ctx": {"_type": "Load", "_fields": {}}}}}}, "orelse": []}}], "test": {"_type": "Name", "_fields": {"id": "color", "ctx": {"_type": "Load", "_fields": {}}}}, "orelse": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "value", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "write", "value": {"_type": "Name", "_fields": {"id": "outfile", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}]}}], "iter": {"_type": "Name", "_fields": {"id": "tokensource", "ctx": {"_type": "Load", "_fields": {}}}}, "orelse": [], "target": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "ttype", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "value", "ctx": {"_type": "Store", "_fields": {}}}}]}}, "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "\n"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "write", "value": {"_type": "Name", "_fields": {"id": "outfile", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "name": "_format_unencoded_with_lineno", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def _format_unencoded_with_lineno(self, tokensource, outfile): self._write_lineno(outfile) for ttype, value in tokensource: if value.endswith("\n"): self._write_lineno(outfile) value = value[:-1] color = self.colorscheme.get(ttype) while color is None: ttype = ttype[:-1] color = self.colorscheme.get(ttype) if color: color = color[self.darkbg] spl = value.split('\n') for line in spl[:-1]: self._write_lineno(outfile) if line: outfile.write(ircformat(color, line[:-1])) if spl[-1]: outfile.write(ircformat(color, spl[-1])) else: outfile.write(value) outfile.write("\n")
14,484
[ 0.03788122534751892, 0.02976207248866558, -0.018586011603474617, 0.0049185678362846375, 0.04240545257925987, 0.0426255501806736, -0.02753664366900921, 0.004799348302185535, 0.010540224611759186, -0.03423738852143288, -0.010093916207551956, -0.023342562839388847, -0.041280508041381836, 0.01...
9
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "read_message", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "ws", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "pending_read", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}], "test": {"_type": "Compare", "_fields": {"ops": [{"_type": "Is", "_fields": {}}], "left": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "pending_read", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "comparators": [{"_type": "Constant", "_fields": {"kind": null, "value": null}}]}}, "orelse": []}}, {"_type": "Assign", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "pending_read", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "response", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Constant", "_fields": {"kind": null, "value": null}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "pending_read", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "If", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "response", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "loads", "value": {"_type": "Name", "_fields": {"id": "json", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "response", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}], "test": {"_type": "Name", "_fields": {"id": "response", "ctx": {"_type": "Load", "_fields": {}}}}, "orelse": []}}, {"_type": "Raise", "_fields": {"exc": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "response", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "Return", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "gen", "value": {"_type": "Name", "_fields": {"id": "tornado", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}, "cause": null}}], "name": "read_msg", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def read_msg(self): # Because the Tornado Websocket client has no way to cancel # a pending read, we have to keep track of them... if self.pending_read is None: self.pending_read = self.ws.read_message() response = yield self.pending_read self.pending_read = None if response: response = json.loads(response) raise tornado.gen.Return(response)
14,485
[ -0.03547659143805504, 0.0046364073641598225, 0.048440076410770416, 0.018568696454167366, 0.014508957043290138, -0.0038550228346139193, 0.005155408289283514, 0.018810896202921867, 0.052176885306835175, 0.022501569241285324, -0.011527584865689278, -0.011890885420143604, -0.0009262723033316433,...
9
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "path", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_http_port", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "port", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Mod", "_fields": {}}, "left": {"_type": "Constant", "_fields": {"kind": null, "value": "ws://127.0.0.1:%d%s"}}, "right": {"_type": "Tuple", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "port", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "path", "ctx": {"_type": "Load", "_fields": {}}}}]}}}}, "targets": [{"_type": "Name", "_fields": {"id": "url", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "url", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "HTTPRequest", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "httpclient", "value": {"_type": "Name", "_fields": {"id": "tornado", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "headers", "value": {"_type": "Dict", "_fields": {"keys": [{"_type": "Constant", "_fields": {"kind": null, "value": "Origin"}}], "values": [{"_type": "BinOp", "_fields": {"op": {"_type": "Mod", "_fields": {}}, "left": {"_type": "Constant", "_fields": {"kind": null, "value": "http://127.0.0.1:%d"}}, "right": {"_type": "Name", "_fields": {"id": "port", "ctx": {"_type": "Load", "_fields": {}}}}}}]}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "request", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "request", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "websocket_connect", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "websocket", "value": {"_type": "Name", "_fields": {"id": "tornado", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "ws", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Raise", "_fields": {"exc": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "ws", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "TestTermClient", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "Return", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "gen", "value": {"_type": "Name", "_fields": {"id": "tornado", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}, "cause": null}}], "name": "get_term_client", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def get_term_client(self, path): port = self.get_http_port() url = 'ws://127.0.0.1:%d%s' % (port, path) request = tornado.httpclient.HTTPRequest(url, headers={'Origin' : 'http://127.0.0.1:%d' % port}) ws = yield tornado.websocket.websocket_connect(request) raise tornado.gen.Return(TestTermClient(ws))
14,486
[ -0.02239413373172283, -0.002209202153608203, 0.07955645024776459, 0.006073732394725084, 0.014035671949386597, -0.005403419025242329, 0.019448531791567802, 0.01986393705010414, 0.040961503982543945, 0.03174705430865288, -0.038897063583135605, -0.050553593784570694, -0.012084524147212505, -0...
10
{"_type": "Module", "_fields": {"body": [{"_type": "ClassDef", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "For", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "url", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_term_client", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "tm", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "read_msg", "value": {"_type": "Name", "_fields": {"id": "tm", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "response", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "response", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": "setup"}}, {"_type": "Dict", "_fields": {"keys": [], "values": []}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "read_msg", "value": {"_type": "Name", "_fields": {"id": "tm", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "response", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "response", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": "stdout"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}, "value": {"_type": "Name", "_fields": {"id": "response", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Name", "_fields": {"id": "len", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertGreater", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "close", "value": {"_type": "Name", "_fields": {"id": "tm", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "iter": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_urls", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "orelse": [], "target": {"_type": "Name", "_fields": {"id": "url", "ctx": {"_type": "Store", "_fields": {}}}}, "type_comment": null}}], "name": "test_basic", "returns": null, "type_params": [], "type_comment": null, "decorator_list": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "gen_test", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "testing", "value": {"_type": "Name", "_fields": {"id": "tornado", "ctx": {"_type": "Load", "_fields": {}}}}}}}}]}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "For", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "url", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_term_client", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "tm", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "read_all_msg", "value": {"_type": "Name", "_fields": {"id": "tm", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "whoami\r"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "write_stdin", "value": {"_type": "Name", "_fields": {"id": "tm", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "read_stdout", "value": {"_type": "Name", "_fields": {"id": "tm", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "stdout", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "other", "ctx": {"_type": "Store", "_fields": {}}}}]}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": {"_type": "Constant", "_fields": {"kind": null, "value": 6}}}}, "value": {"_type": "Name", "_fields": {"id": "stdout", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": "whoami"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "other", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "close", "value": {"_type": "Name", "_fields": {"id": "tm", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "iter": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_urls", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "orelse": [], "target": {"_type": "Name", "_fields": {"id": "url", "ctx": {"_type": "Store", "_fields": {}}}}, "type_comment": null}}], "name": "test_basic_command", "returns": null, "type_params": [], "type_comment": null, "decorator_list": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "gen_test", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "testing", "value": {"_type": "Name", "_fields": {"id": "tornado", "ctx": {"_type": "Load", "_fields": {}}}}}}}}]}}], "name": "CommonTests", "bases": [{"_type": "Name", "_fields": {"id": "TermTestCase", "ctx": {"_type": "Load", "_fields": {}}}}], "keywords": [], "type_params": [], "decorator_list": []}}], "type_ignores": []}}
class CommonTests(TermTestCase): @tornado.testing.gen_test def test_basic(self): for url in self.test_urls: tm = yield self.get_term_client(url) response = yield tm.read_msg() self.assertEqual(response, ['setup', {}]) # Check for initial shell prompt response = yield tm.read_msg() self.assertEqual(response[0], 'stdout') self.assertGreater(len(response[1]), 0) tm.close() @tornado.testing.gen_test def test_basic_command(self): for url in self.test_urls: tm = yield self.get_term_client(url) yield tm.read_all_msg() tm.write_stdin("whoami\r") (stdout, other) = yield tm.read_stdout() self.assertEqual(stdout[:6], "whoami") self.assertEqual(other, []) tm.close()
14,487
[ -0.0276679378002882, -0.014870519749820232, 0.011574819684028625, -0.006837249733507633, 0.013807390816509724, -0.033116474747657776, 0.010106371715664864, 0.05209333077073097, 0.04927603900432587, 0.04233912006020546, -0.010013348422944546, -0.05586744099855423, -0.01677086390554905, -0.0...
9
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "For", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "url", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_term_client", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "tm", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "read_msg", "value": {"_type": "Name", "_fields": {"id": "tm", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "response", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "response", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": "setup"}}, {"_type": "Dict", "_fields": {"keys": [], "values": []}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "read_msg", "value": {"_type": "Name", "_fields": {"id": "tm", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "response", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "response", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": "stdout"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}, "value": {"_type": "Name", "_fields": {"id": "response", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Name", "_fields": {"id": "len", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertGreater", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "close", "value": {"_type": "Name", "_fields": {"id": "tm", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "iter": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_urls", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "orelse": [], "target": {"_type": "Name", "_fields": {"id": "url", "ctx": {"_type": "Store", "_fields": {}}}}, "type_comment": null}}], "name": "test_basic", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def test_basic(self): for url in self.test_urls: tm = yield self.get_term_client(url) response = yield tm.read_msg() self.assertEqual(response, ['setup', {}]) # Check for initial shell prompt response = yield tm.read_msg() self.assertEqual(response[0], 'stdout') self.assertGreater(len(response[1]), 0) tm.close()
14,488
[ -0.03488307446241379, 0.014740414917469025, 0.08504679054021835, -0.023229658603668213, 0.002218779642134905, 0.02284378372132778, -0.008482812903821468, 0.011788473464548588, 0.04329514503479004, 0.03722405061125755, -0.008437794633209705, -0.03557765111327171, -0.03629795089364052, -0.00...
10
{"_type": "Module", "_fields": {"body": [{"_type": "ClassDef", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "/new"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "fetch", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "follow_redirects", "value": {"_type": "Constant", "_fields": {"kind": null, "value": false}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "response", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "code", "value": {"_type": "Name", "_fields": {"id": "response", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 302}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "Location"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "headers", "value": {"_type": "Name", "_fields": {"id": "response", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "url", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 2}}, "value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "/"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "split", "value": {"_type": "Name", "_fields": {"id": "url", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "name", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "name", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "terminals", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "named_tm", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertIn", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "name": "test_new", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": "/named/1"}}]}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": 2}}}}, "right": {"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": "/named/2"}}]}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": 2}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "names", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "names", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_term_clients", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "tms", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "tms", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_pids", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "pids", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "pids", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}, "value": {"_type": "Name", "_fields": {"id": "pids", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 2}}, "value": {"_type": "Name", "_fields": {"id": "pids", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 3}}, "value": {"_type": "Name", "_fields": {"id": "pids", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "pids", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 3}}, "value": {"_type": "Name", "_fields": {"id": "pids", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertNotEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "name": "test_namespace", "returns": null, "type_params": [], "type_comment": null, "decorator_list": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "gen_test", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "testing", "value": {"_type": "Name", "_fields": {"id": "tornado", "ctx": {"_type": "Load", "_fields": {}}}}}}}}]}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "ListComp", "_fields": {"elt": {"_type": "BinOp", "_fields": {"op": {"_type": "Mod", "_fields": {}}, "left": {"_type": "Constant", "_fields": {"kind": null, "value": "/named/%d"}}, "right": {"_type": "Name", "_fields": {"id": "i", "ctx": {"_type": "Load", "_fields": {}}}}}}, "generators": [{"_type": "comprehension", "_fields": {"ifs": [], "iter": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "MAX_TERMS", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}}}], "func": {"_type": "Name", "_fields": {"id": "range", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "target": {"_type": "Name", "_fields": {"id": "i", "ctx": {"_type": "Store", "_fields": {}}}}, "is_async": 0}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "urls", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": {"_type": "Name", "_fields": {"id": "MAX_TERMS", "ctx": {"_type": "Load", "_fields": {}}}}}}, "value": {"_type": "Name", "_fields": {"id": "urls", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_term_clients", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "tms", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "tms", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_pids", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "pids", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Name", "_fields": {"id": "MAX_TERMS", "ctx": {"_type": "Load", "_fields": {}}}}, "value": {"_type": "Name", "_fields": {"id": "urls", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_term_client", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "tm", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "read_msg", "value": {"_type": "Name", "_fields": {"id": "tm", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "msg", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "msg", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": null}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "name": "test_max_terminals", "returns": null, "type_params": [], "type_comment": null, "decorator_list": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "gen_test", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "testing", "value": {"_type": "Name", "_fields": {"id": "tornado", "ctx": {"_type": "Load", "_fields": {}}}}}}}}]}}], "name": "NamedTermTests", "bases": [{"_type": "Name", "_fields": {"id": "TermTestCase", "ctx": {"_type": "Load", "_fields": {}}}}], "keywords": [], "type_params": [], "decorator_list": []}}], "type_ignores": []}}
class NamedTermTests(TermTestCase): def test_new(self): response = self.fetch("/new", follow_redirects=False) self.assertEqual(response.code, 302) url = response.headers["Location"] # Check that the new terminal was created name = url.split('/')[2] self.assertIn(name, self.named_tm.terminals) @tornado.testing.gen_test def test_namespace(self): names = ["/named/1"]*2 + ["/named/2"]*2 tms = yield self.get_term_clients(names) pids = yield self.get_pids(tms) self.assertEqual(pids[0], pids[1]) self.assertEqual(pids[2], pids[3]) self.assertNotEqual(pids[0], pids[3]) @tornado.testing.gen_test def test_max_terminals(self): urls = ["/named/%d" % i for i in range(MAX_TERMS+1)] tms = yield self.get_term_clients(urls[:MAX_TERMS]) pids = yield self.get_pids(tms) # MAX_TERMS+1 should fail tm = yield self.get_term_client(urls[MAX_TERMS]) msg = yield tm.read_msg() self.assertEqual(msg, None)
14,489
[ -0.007546776439994574, -0.009766781702637672, 0.04494579881429672, -0.0029346852097660303, 0.004743865225464106, -0.032245881855487823, -0.026491232216358185, 0.042887020856142044, 0.021431108936667442, 0.0364130400121212, -0.01085197925567627, -0.03618980199098587, -0.007354541216045618, ...
9
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "For", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "url", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_term_client", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "tm", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "read_all_msg", "value": {"_type": "Name", "_fields": {"id": "tm", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "whoami\r"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "write_stdin", "value": {"_type": "Name", "_fields": {"id": "tm", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "read_stdout", "value": {"_type": "Name", "_fields": {"id": "tm", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Tuple", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "elts": [{"_type": "Name", "_fields": {"id": "stdout", "ctx": {"_type": "Store", "_fields": {}}}}, {"_type": "Name", "_fields": {"id": "other", "ctx": {"_type": "Store", "_fields": {}}}}]}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": {"_type": "Constant", "_fields": {"kind": null, "value": 6}}}}, "value": {"_type": "Name", "_fields": {"id": "stdout", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": "whoami"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "other", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "close", "value": {"_type": "Name", "_fields": {"id": "tm", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "iter": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "test_urls", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "orelse": [], "target": {"_type": "Name", "_fields": {"id": "url", "ctx": {"_type": "Store", "_fields": {}}}}, "type_comment": null}}], "name": "test_basic_command", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def test_basic_command(self): for url in self.test_urls: tm = yield self.get_term_client(url) yield tm.read_all_msg() tm.write_stdin("whoami\r") (stdout, other) = yield tm.read_stdout() self.assertEqual(stdout[:6], "whoami") self.assertEqual(other, []) tm.close()
14,490
[ -0.014790820889174938, -0.0038890838623046875, 0.09579858928918839, -0.029144207015633583, -0.009842321276664734, 0.005095451604574919, -0.02368992008268833, -0.01593909226357937, 0.013997967354953289, 0.024373413994908333, 0.0008026788709685206, -0.01757947914302349, 0.024428093805909157, ...
8
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": "/named/1"}}]}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": 2}}}}, "right": {"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": "/named/2"}}]}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": 2}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "names", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "names", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_term_clients", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "tms", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "tms", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_pids", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "pids", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "pids", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}, "value": {"_type": "Name", "_fields": {"id": "pids", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 2}}, "value": {"_type": "Name", "_fields": {"id": "pids", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 3}}, "value": {"_type": "Name", "_fields": {"id": "pids", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "pids", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 3}}, "value": {"_type": "Name", "_fields": {"id": "pids", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertNotEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "name": "test_namespace", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def test_namespace(self): names = ["/named/1"]*2 + ["/named/2"]*2 tms = yield self.get_term_clients(names) pids = yield self.get_pids(tms) self.assertEqual(pids[0], pids[1]) self.assertEqual(pids[2], pids[3]) self.assertNotEqual(pids[0], pids[3])
14,491
[ -0.03954240679740906, 0.007742749992758036, 0.02005605399608612, -0.02926189824938774, 0.03244704380631447, 0.03226577490568161, -0.0009427575278095901, 0.04057822749018669, 0.05401798337697983, 0.028614511713385582, 0.0025393760297447443, -0.02368142083287239, -0.01887780986726284, -0.013...
8
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "/new"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "fetch", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "follow_redirects", "value": {"_type": "Constant", "_fields": {"kind": null, "value": false}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "response", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "code", "value": {"_type": "Name", "_fields": {"id": "response", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 302}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "Location"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "headers", "value": {"_type": "Name", "_fields": {"id": "response", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "targets": [{"_type": "Name", "_fields": {"id": "url", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 2}}, "value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "/"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "split", "value": {"_type": "Name", "_fields": {"id": "url", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "name", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "name", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "terminals", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "named_tm", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertIn", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "name": "test_new", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def test_new(self): response = self.fetch("/new", follow_redirects=False) self.assertEqual(response.code, 302) url = response.headers["Location"] # Check that the new terminal was created name = url.split('/')[2] self.assertIn(name, self.named_tm.terminals)
14,492
[ -0.0033966905903071165, 0.013440382666885853, 0.10986514389514923, 0.008563253097236156, 0.005735450424253941, 0.008257185108959675, 0.022156670689582825, 0.022010289132595062, 0.03473207727074623, 0.01900283806025982, 0.019295597448945045, -0.042955994606018066, -0.04074697941541672, 0.00...
10
{"_type": "Module", "_fields": {"body": [{"_type": "ClassDef", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": "/unique"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "/unique"}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_term_clients", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "tms", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "tms", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_pids", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "pids", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "pids", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}, "value": {"_type": "Name", "_fields": {"id": "pids", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertNotEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "name": "test_unique_processes", "returns": null, "type_params": [], "type_comment": null, "decorator_list": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "gen_test", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "testing", "value": {"_type": "Name", "_fields": {"id": "tornado", "ctx": {"_type": "Load", "_fields": {}}}}}}}}]}}, {"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": "/unique"}}]}}, "right": {"_type": "Name", "_fields": {"id": "MAX_TERMS", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_term_clients", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "tms", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "tms", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_pids", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "pids", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "pids", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "set", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}], "func": {"_type": "Name", "_fields": {"id": "len", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, {"_type": "Name", "_fields": {"id": "MAX_TERMS", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "/unique"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_term_client", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "tm", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "read_msg", "value": {"_type": "Name", "_fields": {"id": "tm", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "msg", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "msg", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": null}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "close", "value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "tms", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "read_msg", "value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "tms", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "msg", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "msg", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": null}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEquals", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "/unique"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_term_client", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "tm", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "read_msg", "value": {"_type": "Name", "_fields": {"id": "tm", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "msg", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "msg", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": "setup"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEquals", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "name": "test_max_terminals", "returns": null, "type_params": [], "type_comment": null, "decorator_list": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "gen_test", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "testing", "value": {"_type": "Name", "_fields": {"id": "tornado", "ctx": {"_type": "Load", "_fields": {}}}}}}}}]}}], "name": "UniqueTermTests", "bases": [{"_type": "Name", "_fields": {"id": "TermTestCase", "ctx": {"_type": "Load", "_fields": {}}}}], "keywords": [], "type_params": [], "decorator_list": []}}], "type_ignores": []}}
class UniqueTermTests(TermTestCase): @tornado.testing.gen_test def test_unique_processes(self): tms = yield self.get_term_clients(["/unique", "/unique"]) pids = yield self.get_pids(tms) self.assertNotEqual(pids[0], pids[1]) @tornado.testing.gen_test def test_max_terminals(self): tms = yield self.get_term_clients(['/unique'] * MAX_TERMS) pids = yield self.get_pids(tms) self.assertEqual(len(set(pids)), MAX_TERMS) # All PIDs unique # MAX_TERMS+1 should fail tm = yield self.get_term_client("/unique") msg = yield tm.read_msg() self.assertEqual(msg, None) # Connection closed # Close one tms[0].close() msg = yield tms[0].read_msg() # Closed self.assertEquals(msg, None) # Should be able to open back up to MAX_TERMS tm = yield self.get_term_client("/unique") msg = yield tm.read_msg() self.assertEquals(msg[0], 'setup')
14,493
[ -0.008081458508968353, 0.040139324963092804, 0.10386014729738235, -0.0034289786126464605, -0.018913153558969498, 0.0027872570790350437, -0.001297546667046845, 0.048319507390260696, 0.01637447439134121, 0.04747328162193298, 0.018377209082245827, -0.048911865800619125, -0.0268112625926733, -...
9
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "ListComp", "_fields": {"elt": {"_type": "BinOp", "_fields": {"op": {"_type": "Mod", "_fields": {}}, "left": {"_type": "Constant", "_fields": {"kind": null, "value": "/named/%d"}}, "right": {"_type": "Name", "_fields": {"id": "i", "ctx": {"_type": "Load", "_fields": {}}}}}}, "generators": [{"_type": "comprehension", "_fields": {"ifs": [], "iter": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Add", "_fields": {}}, "left": {"_type": "Name", "_fields": {"id": "MAX_TERMS", "ctx": {"_type": "Load", "_fields": {}}}}, "right": {"_type": "Constant", "_fields": {"kind": null, "value": 1}}}}], "func": {"_type": "Name", "_fields": {"id": "range", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "target": {"_type": "Name", "_fields": {"id": "i", "ctx": {"_type": "Store", "_fields": {}}}}, "is_async": 0}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "urls", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Slice", "_fields": {"step": null, "lower": null, "upper": {"_type": "Name", "_fields": {"id": "MAX_TERMS", "ctx": {"_type": "Load", "_fields": {}}}}}}, "value": {"_type": "Name", "_fields": {"id": "urls", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_term_clients", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "tms", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "tms", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_pids", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "pids", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Name", "_fields": {"id": "MAX_TERMS", "ctx": {"_type": "Load", "_fields": {}}}}, "value": {"_type": "Name", "_fields": {"id": "urls", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_term_client", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "tm", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "read_msg", "value": {"_type": "Name", "_fields": {"id": "tm", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "msg", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "msg", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": null}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "name": "test_max_terminals", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def test_max_terminals(self): urls = ["/named/%d" % i for i in range(MAX_TERMS+1)] tms = yield self.get_term_clients(urls[:MAX_TERMS]) pids = yield self.get_pids(tms) # MAX_TERMS+1 should fail tm = yield self.get_term_client(urls[MAX_TERMS]) msg = yield tm.read_msg() self.assertEqual(msg, None)
14,494
[ -0.04795168340206146, 0.02967262826859951, 0.014679315499961376, -0.03705153614282608, 0.027115803211927414, -0.03220702335238457, -0.02219279296696186, 0.029381059110164642, 0.01648479327559471, 0.04656112939119339, 0.007849901914596558, -0.038464516401290894, 0.06611859798431396, -0.0381...
9
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "request", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "BoolOp", "_fields": {"op": {"_type": "Or", "_fields": {}}, "values": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_bad_debug_urls", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": []}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "debug_urls", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "If", "_fields": {"body": [{"_type": "Return", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_bad_run_start_action", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Name", "_fields": {"id": "debug_urls", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "OnRunStartResponse", "value": {"_type": "Name", "_fields": {"id": "framework", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "test": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_bad_run_start_action", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "orelse": [{"_type": "Return", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "DEBUG_RUN", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "OnRunStartAction", "value": {"_type": "Name", "_fields": {"id": "framework", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Name", "_fields": {"id": "debug_urls", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "OnRunStartResponse", "value": {"_type": "Name", "_fields": {"id": "framework", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}]}}], "name": "on_run_start", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def on_run_start(self, request): debug_urls = self._bad_debug_urls or [] if self._bad_run_start_action: return framework.OnRunStartResponse( self._bad_run_start_action, debug_urls) else: return framework.OnRunStartResponse( framework.OnRunStartAction.DEBUG_RUN, debug_urls)
14,495
[ 0.015630457550287247, 0.03903999552130699, 0.09068846702575684, 0.012926576659083366, 0.001619436894543469, -0.0009380443370901048, 0.02955472283065319, 0.046211786568164825, 0.028889596462249756, 0.016367878764867783, 0.03979187831282616, -0.04334885627031326, -0.026041122153401375, 0.017...
9
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "BinOp", "_fields": {"op": {"_type": "Mult", "_fields": {}}, "left": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": "/unique"}}]}}, "right": {"_type": "Name", "_fields": {"id": "MAX_TERMS", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_term_clients", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "tms", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "tms", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_pids", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "pids", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "pids", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Name", "_fields": {"id": "set", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}], "func": {"_type": "Name", "_fields": {"id": "len", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, {"_type": "Name", "_fields": {"id": "MAX_TERMS", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "/unique"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_term_client", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "tm", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "read_msg", "value": {"_type": "Name", "_fields": {"id": "tm", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "msg", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "msg", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": null}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "close", "value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "tms", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "read_msg", "value": {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "tms", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "msg", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "msg", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": null}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEquals", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": "/unique"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "get_term_client", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "tm", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Yield", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "read_msg", "value": {"_type": "Name", "_fields": {"id": "tm", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, "targets": [{"_type": "Name", "_fields": {"id": "msg", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, "value": {"_type": "Name", "_fields": {"id": "msg", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": "setup"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEquals", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "name": "test_max_terminals", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def test_max_terminals(self): tms = yield self.get_term_clients(['/unique'] * MAX_TERMS) pids = yield self.get_pids(tms) self.assertEqual(len(set(pids)), MAX_TERMS) # All PIDs unique # MAX_TERMS+1 should fail tm = yield self.get_term_client("/unique") msg = yield tm.read_msg() self.assertEqual(msg, None) # Connection closed # Close one tms[0].close() msg = yield tms[0].read_msg() # Closed self.assertEquals(msg, None) # Should be able to open back up to MAX_TERMS tm = yield self.get_term_client("/unique") msg = yield tm.read_msg() self.assertEquals(msg[0], 'setup')
14,496
[ 0.018486090004444122, -0.007734938524663448, 0.02434178628027439, -0.035181302577257156, 0.026038406416773796, 0.014209194108843803, 0.04083670303225517, 0.03082193247973919, 0.08355854451656342, 0.0031428709626197815, 0.046916261315345764, -0.017107587307691574, -0.00029823402292095125, 0...
8
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 0}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "sess_init_count"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_observer", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_sess", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_dump_root", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_observer", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Name", "_fields": {"id": "TestDebugWrapperSession", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "wrapper_sess", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "sess_init_count"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_observer", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_sess", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "request_sess"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_observer", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "wrapper_sess", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "SessionInterface", "value": {"_type": "Name", "_fields": {"id": "session", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Name", "_fields": {"id": "isinstance", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertTrue", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sess_str", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_sess", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "sess_str", "value": {"_type": "Name", "_fields": {"id": "wrapper_sess", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "graph", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_sess", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "graph", "value": {"_type": "Name", "_fields": {"id": "wrapper_sess", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "graph_def", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_sess", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "graph_def", "value": {"_type": "Name", "_fields": {"id": "wrapper_sess", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "With", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_p", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "partial_run_setup", "value": {"_type": "Name", "_fields": {"id": "wrapper_sess", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "NotImplementedError", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertRaises", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "name": "testSessionInit", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def testSessionInit(self): self.assertEqual(0, self._observer["sess_init_count"]) wrapper_sess = TestDebugWrapperSession(self._sess, self._dump_root, self._observer) # Assert that on-session-init callback is invoked. self.assertEqual(1, self._observer["sess_init_count"]) # Assert that the request to the on-session-init callback carries the # correct session object. self.assertEqual(self._sess, self._observer["request_sess"]) # Verify that the wrapper session implements the session.SessionInterface. self.assertTrue(isinstance(wrapper_sess, session.SessionInterface)) self.assertEqual(self._sess.sess_str, wrapper_sess.sess_str) self.assertEqual(self._sess.graph, wrapper_sess.graph) self.assertEqual(self._sess.graph_def, wrapper_sess.graph_def) # Check that the partial_run_setup and partial_run are not implemented for # the debug wrapper session. with self.assertRaises(NotImplementedError): wrapper_sess.partial_run_setup(self._p)
14,497
[ 0.04064019396901131, -0.011755592189729214, 0.010760026052594185, -0.031277917325496674, -0.016891658306121826, 0.012355568818747997, 0.04794541001319885, 0.04570373520255089, 0.03565577045083046, -0.018474014475941658, 0.008511760272085667, -0.03220095857977867, -0.010918261483311653, -0....
8
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Dict", "_fields": {"keys": [{"_type": "Constant", "_fields": {"kind": null, "value": "sess_init_count"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "request_sess"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "on_run_start_count"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "run_fetches"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "run_feed_dict"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "on_run_end_count"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "performed_action"}}, {"_type": "Constant", "_fields": {"kind": null, "value": "tf_error"}}], "values": [{"_type": "Constant", "_fields": {"kind": null, "value": 0}}, {"_type": "Constant", "_fields": {"kind": null, "value": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, {"_type": "Constant", "_fields": {"kind": null, "value": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0}}, {"_type": "Constant", "_fields": {"kind": null, "value": null}}, {"_type": "Constant", "_fields": {"kind": null, "value": null}}]}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "_observer", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "mkdtemp", "value": {"_type": "Name", "_fields": {"id": "tempfile", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "_dump_root", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "Session", "value": {"_type": "Name", "_fields": {"id": "session", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "_sess", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 5.0}}, {"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}]}}, {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": 0.0}}]}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "array", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "_a_init_val", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2.0}}]}}, {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 1.0}}}}]}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "array", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "_b_init_val", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "UnaryOp", "_fields": {"op": {"_type": "USub", "_fields": {}}, "operand": {"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}}}]}}, {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 6.0}}]}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "array", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "_c_val", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_a_init_val", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "constant_op", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "shape", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2}}, {"_type": "Constant", "_fields": {"kind": null, "value": 2}}]}}}}, {"_type": "keyword", "_fields": {"arg": "name", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "a1_init"}}}}]}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "_a_init", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_b_init_val", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "constant_op", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "shape", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}]}}}}, {"_type": "keyword", "_fields": {"arg": "name", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "b_init"}}}}]}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "_b_init", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "placeholder", "value": {"_type": "Name", "_fields": {"id": "array_ops", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "dtype", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "float64", "value": {"_type": "Name", "_fields": {"id": "dtypes", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "keyword", "_fields": {"arg": "name", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "ph"}}}}]}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "_ph", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_a_init", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "Variable", "value": {"_type": "Name", "_fields": {"id": "variables", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "name", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "a1"}}}}]}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "_a", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_b_init", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "Variable", "value": {"_type": "Name", "_fields": {"id": "variables", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "name", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "b"}}}}]}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "_b", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_c_val", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "constant_op", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "shape", "value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 2}}, {"_type": "Constant", "_fields": {"kind": null, "value": 1}}]}}}}, {"_type": "keyword", "_fields": {"arg": "name", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "c"}}}}]}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "_c", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_a", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_b", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "matmul", "value": {"_type": "Name", "_fields": {"id": "math_ops", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "name", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "p1"}}}}]}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "_p", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_a", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_ph", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "matmul", "value": {"_type": "Name", "_fields": {"id": "math_ops", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "name", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "q"}}}}]}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "_q", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_p", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_c", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "add", "value": {"_type": "Name", "_fields": {"id": "math_ops", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "name", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "s"}}}}]}}, "targets": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Store", "_fields": {}}, "attr": "_s", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "initializer", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_a", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "run", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_sess", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "initializer", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_b", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "run", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_sess", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, "keywords": []}}}}], "name": "setUp", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def setUp(self): self._observer = { "sess_init_count": 0, "request_sess": None, "on_run_start_count": 0, "run_fetches": None, "run_feed_dict": None, "on_run_end_count": 0, "performed_action": None, "tf_error": None, } self._dump_root = tempfile.mkdtemp() self._sess = session.Session() self._a_init_val = np.array([[5.0, 3.0], [-1.0, 0.0]]) self._b_init_val = np.array([[2.0], [-1.0]]) self._c_val = np.array([[-4.0], [6.0]]) self._a_init = constant_op.constant( self._a_init_val, shape=[2, 2], name="a1_init") self._b_init = constant_op.constant( self._b_init_val, shape=[2, 1], name="b_init") self._ph = array_ops.placeholder(dtype=dtypes.float64, name="ph") self._a = variables.Variable(self._a_init, name="a1") self._b = variables.Variable(self._b_init, name="b") self._c = constant_op.constant(self._c_val, shape=[2, 1], name="c") # Matrix product of a and b. self._p = math_ops.matmul(self._a, self._b, name="p1") # Matrix product of a and ph. self._q = math_ops.matmul(self._a, self._ph, name="q") # Sum of two vectors. self._s = math_ops.add(self._p, self._c, name="s") # Initialize the variables. self._sess.run(self._a.initializer) self._sess.run(self._b.initializer)
14,498
[ -0.05016573145985603, 0.026096802204847336, 0.013350168243050575, -0.02513114921748638, 0.02194448933005333, -0.013470875099301338, -0.012613857164978981, 0.025831246748566628, 0.018045661970973015, 0.044685643166303635, 0.0012870358768850565, -0.048596542328596115, 0.06923740357160568, -0...
8
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_sess", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Name", "_fields": {"id": "TestDebugWrapperSessionBadAction", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "bad_debug_urls", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "file://foo"}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "wrapper", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "With", "_fields": {"body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_s", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "run", "value": {"_type": "Name", "_fields": {"id": "wrapper", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "TypeError", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Constant", "_fields": {"kind": null, "value": "Expected type .*; got type .*"}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertRaisesRegexp", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "name": "testRunStartBadURLs", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def testRunStartBadURLs(self): # debug_urls ought to be a list of str, not a str. So an exception should # be raised during a run() call. wrapper = TestDebugWrapperSessionBadAction( self._sess, bad_debug_urls="file://foo") with self.assertRaisesRegexp(TypeError, "Expected type .*; got type .*"): wrapper.run(self._s)
14,499
[ 0.012905276380479336, 0.0042012413032352924, 0.004388613626360893, -0.06604878604412079, 0.03133803978562355, 0.014732157811522484, 0.019662395119667053, 0.043891992419958115, 0.06473717838525772, 0.01962726190686226, 0.0389266237616539, -0.015762705355882645, 0.03576471284031868, -0.01229...
8
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_sess", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_dump_root", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_observer", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Name", "_fields": {"id": "TestDebugWrapperSession", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "wrapper", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 0}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "on_run_start_count"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_observer", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 0}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "on_run_end_count"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_observer", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_s", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "run", "value": {"_type": "Name", "_fields": {"id": "wrapper", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "s", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Call", "_fields": {"args": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 3.0}}]}}, {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"kind": null, "value": 4.0}}]}}]}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "array", "value": {"_type": "Name", "_fields": {"id": "np", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, {"_type": "Name", "_fields": {"id": "s", "ctx": {"_type": "Load", "_fields": {}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertAllClose", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "on_run_start_count"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_observer", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_s", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "run_fetches"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_observer", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "run_feed_dict"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_observer", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertIsNone", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_dump_root", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "DebugDumpDir", "value": {"_type": "Name", "_fields": {"id": "debug_data", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "dump", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 7}}, {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "dumped_tensor_data", "value": {"_type": "Name", "_fields": {"id": "dump", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Name", "_fields": {"id": "len", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 1}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "on_run_end_count"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_observer", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "DEBUG_RUN", "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "OnRunStartAction", "value": {"_type": "Name", "_fields": {"id": "framework", "ctx": {"_type": "Load", "_fields": {}}}}}}}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "performed_action"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_observer", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "tf_error"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_observer", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertIsNone", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "name": "testSessionRun", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def testSessionRun(self): wrapper = TestDebugWrapperSession( self._sess, self._dump_root, self._observer) # Check initial state of the observer. self.assertEqual(0, self._observer["on_run_start_count"]) self.assertEqual(0, self._observer["on_run_end_count"]) s = wrapper.run(self._s) # Assert the run return value is correct. self.assertAllClose(np.array([[3.0], [4.0]]), s) # Assert the on-run-start method is invoked. self.assertEqual(1, self._observer["on_run_start_count"]) # Assert the on-run-start request reflects the correct fetch. self.assertEqual(self._s, self._observer["run_fetches"]) # Assert the on-run-start request reflects the correct feed_dict. self.assertIsNone(self._observer["run_feed_dict"]) # Assert the file debug URL has led to dump on the filesystem. dump = debug_data.DebugDumpDir(self._dump_root) self.assertEqual(7, len(dump.dumped_tensor_data)) # Assert the on-run-end method is invoked. self.assertEqual(1, self._observer["on_run_end_count"]) # Assert the performed action field in the on-run-end callback request is # correct. self.assertEqual( framework.OnRunStartAction.DEBUG_RUN, self._observer["performed_action"]) # No TensorFlow runtime error should have happened. self.assertIsNone(self._observer["tf_error"])
14,500
[ 0.012987631373107433, -0.01018661167472601, 0.042494092136621475, -0.025448575615882874, 0.06947484612464905, 0.04979589581489563, 0.005745680071413517, 0.02535281330347061, 0.08264203369617462, -0.03145759925246239, 0.01885301247239113, -0.010102820582687855, 0.030212702229619026, 0.03002...
9
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_sess", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_dump_root", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_observer", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}], "func": {"_type": "Name", "_fields": {"id": "TestDebugWrapperSession", "ctx": {"_type": "Load", "_fields": {}}}}, "keywords": []}}, "targets": [{"_type": "Name", "_fields": {"id": "wrapper", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "With", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 42}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "constant", "value": {"_type": "Name", "_fields": {"id": "constant_op", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": [{"_type": "keyword", "_fields": {"arg": "name", "value": {"_type": "Constant", "_fields": {"kind": null, "value": "foo"}}}}]}}, "targets": [{"_type": "Name", "_fields": {"id": "foo", "ctx": {"_type": "Store", "_fields": {}}}}], "type_comment": null}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Constant", "_fields": {"kind": null, "value": 42}}, {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "eval", "value": {"_type": "Name", "_fields": {"id": "foo", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}, {"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"args": [{"_type": "Name", "_fields": {"id": "foo", "ctx": {"_type": "Load", "_fields": {}}}}, {"_type": "Subscript", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "slice": {"_type": "Constant", "_fields": {"kind": null, "value": "run_fetches"}}, "value": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "_observer", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}}}], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "assertEqual", "value": {"_type": "Name", "_fields": {"id": "self", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}}}], "items": [{"_type": "withitem", "_fields": {"context_expr": {"_type": "Call", "_fields": {"args": [], "func": {"_type": "Attribute", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "attr": "as_default", "value": {"_type": "Name", "_fields": {"id": "wrapper", "ctx": {"_type": "Load", "_fields": {}}}}}}, "keywords": []}}, "optional_vars": null}}], "type_comment": null}}], "name": "testUsingWrappedSessionShouldSupportEvalWithAsDefault", "returns": null, "type_params": [], "type_comment": null, "decorator_list": []}}], "type_ignores": []}}
def testUsingWrappedSessionShouldSupportEvalWithAsDefault(self): wrapper = TestDebugWrapperSession(self._sess, self._dump_root, self._observer) with wrapper.as_default(): foo = constant_op.constant(42, name="foo") self.assertEqual(42, foo.eval()) self.assertEqual(foo, self._observer["run_fetches"])