def decode_data(obj):
"""Decode a serialised data object.
Parameter
---------
obj : Python dictionary
A dictionary describing a serialised data object.
"""
try:
if TYPES['str'] == obj[b'type']:
return decode_str(obj[b'data'])
elif TYPES['ndarray'] == obj[b'type']:
return np.fromstring(obj[b'data'], dtype=np.dtype(
obj[b'dtype'])).reshape(obj[b'shape'])
else:
# Assume the user know what they are doing
return obj
except KeyError:
# Assume the user know what they are doing
return obj
评论列表
文章目录