提交 dfdea75f authored 作者: James Bergstra's avatar James Bergstra

Removing scipy.py file.

Rationale: its name shadowed the scipy package, and it was not successful in simplifying other modules' code that had to do scipy version checks. (Which is only two places anyway).
上级 fe7f1d09
import numpy import numpy
import theano import theano
import theano.scipy # To know if scipy is available.
from theano import tensor, function from theano import tensor, function
from theano.tensor.basic import _allclose from theano.tensor.basic import _allclose
try:
import scipy
if scipy.__version__ < '0.7':
raise ImportError()
use_scipy = True
except ImportError:
use_scipy = False
# The one in comment are not tested... # The one in comment are not tested...
from theano.sandbox.linalg.ops import (cholesky, from theano.sandbox.linalg.ops import (cholesky,
matrix_inverse, matrix_inverse,
...@@ -75,7 +82,7 @@ def test_inverse_grad(): ...@@ -75,7 +82,7 @@ def test_inverse_grad():
def test_det_grad(): def test_det_grad():
# If scipy is not available, this test will fail, thus we skip it. # If scipy is not available, this test will fail, thus we skip it.
if not theano.scipy.scipy_available: if not use_scipy:
raise SkipTest('Scipy is not available') raise SkipTest('Scipy is not available')
rng = numpy.random.RandomState(1234) rng = numpy.random.RandomState(1234)
......
"""
This file is used to check if scipy is available. We do it at only one
place to localise this check. It is to the module to check the scipy
version.
"""
try:
import scipy
scipy_available = True
except ImportError:
scipy_available = False
import sys import sys
import theano.scipy try:
enable_sparse = False
if theano.scipy.scipy_available:
import scipy import scipy
if scipy.__version__ >= '0.7': enable_sparse = scipy.__version__ >= '0.7'
enable_sparse = True if not enable_sparse:
else: sys.stderr.write("WARNING: scipy version = %s."
sys.stderr.write("WARNING: scipy version = %s. We request version >=0.7.0 for the sparse code as it has bugs fixed in the sparse matrix code.\n" % scipy.__version__) " We request version >=0.7.0 for the sparse code as it has"
else: " bugs fixed in the sparse matrix code.\n" % scipy.__version__)
sys.stderr.write("WARNING: scipy can't be imported. We disable the sparse matrix code.") except ImportError:
enable_sparse = False
sys.stderr.write("WARNING: scipy can't be imported."
" We disable the sparse matrix code.")
if enable_sparse: if enable_sparse:
from basic import * from basic import *
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论