提交 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,12 +33,18 @@ def main(): ...@@ -32,12 +33,18 @@ 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
# 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: try:
import theano from theano import config
if theano.config.device != "cpu": if config.device != "cpu":
raise ValueError("Theano tests must be run with device=cpu." raise ValueError("Theano tests must be run with device=cpu."
" This will also run GPU tests when possible.") " This will also run GPU tests when possible.")
except ImportError: except ImportError:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论