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

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

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