提交 62882b0c authored 作者: Frederic's avatar Frederic

Don't import theano before calling nose.main()

上级 6a44266f
......@@ -20,6 +20,7 @@ import logging
_logger = logging.getLogger('theano.bin.theano-nose')
_logger.setLevel(logging.WARN)
import os
import nose
import textwrap
import sys
......@@ -32,12 +33,18 @@ def main():
import theano
sys.argv[i] = theano.__path__[0]
# Many Theano tests suppose device=cpu.
# I don't know how to do this tests only if we use theano-nose on Theano tests.
# So I make the try..except in case the script get reused elsewhere.
# Many Theano tests suppose device=cpu, so we need to raise an
# error if device==gpu.
# I don't know how to do this check only if we use theano-nose on
# Theano tests. So I make an try..except in case the script get
# reused elsewhere.
# We should not import theano before call nose.main()
# As this cause import problem with nosetests.
# Should we find a way to don't modify sys.path?
if not os.path.exists('theano/__init__.py'):
try:
import theano
if theano.config.device != "cpu":
from theano import config
if config.device != "cpu":
raise ValueError("Theano tests must be run with device=cpu."
" This will also run GPU tests when possible.")
except ImportError:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论