def _unpack_ndarray(cls, buf, offset):
dtype, offset = cls._unpack_string(buf, offset)
shape_len = unpack_from("I", buf, offset)[0]
offset += 4
shape = []
for i in range(0, shape_len):
item = unpack_from("I", buf, offset)[0]
offset += 4
shape.append(item)
reslen = unpack_from("I", buf, offset)[0]
offset += 4
res = np.frombuffer(buf[offset:offset+reslen], dtype=np.dtype(dtype))
res = res.reshape(shape)
offset += reslen
return res, offset
评论列表
文章目录