def write_np_values(values, f):
"""
Arguments:
values: {str: np.array}
f: filename or filelike object
"""
with ZipFile(f, 'w') as zf:
for k, v in values.items():
# Need to do this because Python zipfile has some odd support for filenames:
# http://bugs.python.org/issue24110
if len(k) == 16 and isinstance(k, six.binary_type): # valid UUID bytes
zf.writestr(str(uuid.UUID(bytes=k)), v.tostring())
else:
zf.writestr(six.u(k), v.tostring())
zf.writestr(MANIFEST_FILENAME, json_dumps_manifest(values))
评论列表
文章目录