MCPcopy Create free account
hub / github.com/google-research/language / default

Method default

language/labs/drkit/evaluate.py:51–59  ·  view source on GitHub ↗
(self, obj)

Source from the content-addressed store, hash-verified

49 """Special json encoder for numpy types."""
50
51 def default(self, obj):
52 if isinstance(obj, (np.int_, np.intc, np.intp, np.int8, np.int16, np.int32,
53 np.int64, np.uint8, np.uint16, np.uint32, np.uint64)):
54 return int(obj)
55 elif isinstance(obj, (np.float16, np.float32, np.float64)):
56 return float(obj)
57 elif isinstance(obj, (np.ndarray,)): # This is the fix
58 return obj.tolist()
59 return json.JSONEncoder.default(self, obj)
60
61
62def wikimovie_eval_fn(dataset, results, name_map, output_prediction_file,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected