MCPcopy Create free account
hub / github.com/Robbyant/lingbot-va / pack_array

Function pack_array

wan_va/utils/Simple_Remote_Infer/deploy/msgpack_numpy.py:21–42  ·  view source on GitHub ↗
(obj)

Source from the content-addressed store, hash-verified

19
20
21def pack_array(obj):
22 if (isinstance(
23 obj,
24 (np.ndarray, np.generic))) and obj.dtype.kind in ("V", "O", "c"):
25 raise ValueError(f"Unsupported dtype: {obj.dtype}")
26
27 if isinstance(obj, np.ndarray):
28 return {
29 b"__ndarray__": True,
30 b"data": obj.tobytes(),
31 b"dtype": obj.dtype.str,
32 b"shape": obj.shape,
33 }
34
35 if isinstance(obj, np.generic):
36 return {
37 b"__npgeneric__": True,
38 b"data": obj.item(),
39 b"dtype": obj.dtype.str,
40 }
41
42 return obj
43
44
45def unpack_array(obj):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected