提交 6fdfdb4e authored 作者: Olivier Delalleau's avatar Olivier Delalleau

Merge pull request #1123 from goodfeli/master

Fix import
...@@ -1153,6 +1153,12 @@ def hex_digest(x): ...@@ -1153,6 +1153,12 @@ def hex_digest(x):
Returns a short, mostly hexadecimal hash of a numpy ndarray Returns a short, mostly hexadecimal hash of a numpy ndarray
""" """
global hashlib
if hashlib is None:
try:
import hashlib
except ImportError:
raise RuntimeError("Can't run hex_digest because hashlib is not available.")
assert isinstance(x, np.ndarray) assert isinstance(x, np.ndarray)
rval = hashlib.md5(x.tostring()).hexdigest() rval = hashlib.md5(x.tostring()).hexdigest()
# hex digest must be annotated with strides to avoid collisions # hex digest must be annotated with strides to avoid collisions
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论