MCPcopy Create free account
hub / github.com/InternRobotics/UniHSI / default

Method default

unihsi/poselib/poselib/core/backend/abstract.py:62–84  ·  view source on GitHub ↗
(self, obj)

Source from the content-addressed store, hash-verified

60 """ Special json encoder for numpy types """
61
62 def default(self, obj):
63 if isinstance(
64 obj,
65 (
66 np.int_,
67 np.intc,
68 np.intp,
69 np.int8,
70 np.int16,
71 np.int32,
72 np.int64,
73 np.uint8,
74 np.uint16,
75 np.uint32,
76 np.uint64,
77 ),
78 ):
79 return int(obj)
80 elif isinstance(obj, (np.float_, np.float16, np.float32, np.float64)):
81 return float(obj)
82 elif isinstance(obj, (np.ndarray,)):
83 return dict(__ndarray__=obj.tolist(), dtype=str(obj.dtype), shape=obj.shape)
84 return json.JSONEncoder.default(self, obj)
85
86
87def json_numpy_obj_hook(dct):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected