提交 2848ff23 authored 作者: Olivier Delalleau's avatar Olivier Delalleau

Fixed some broken tests when scipy is not available

上级 c2ee569c
import numpy
import theano
import theano.sparse # To know if scipy is available.
from theano import tensor, function
from theano.tensor.basic import _allclose
from theano.sandbox.linalg.ops import *
from nose.plugins.skip import SkipTest
if 0:
def test_cholesky():
#TODO: test upper and lower triangular
......@@ -59,6 +63,11 @@ def test_inverse_grad():
def test_det_grad():
# If scipy is not available, this test will fail, thus we skip it.
# Note that currently we re-use the `enable_sparse` flag, but it may be
# cleaner to have a different `scipy_available` flag in the future.
if not theano.sparse.enable_sparse:
raise SkipTest('Scipy is not available')
rng = numpy.random.RandomState(1234)
r = rng.randn(5,5)
......
import sys
from nose.plugins.skip import SkipTest
import theano.sparse
if not theano.sparse.enable_sparse:
raise SkipTest('Optional package sparse disabled')
from theano import function, Mode
from theano.gof import OpWiseCLinker
import theano, numpy
import theano.tensor as T
import theano.sparse
import scipy.sparse
from scipy.signal import convolve2d
......
import unittest
import theano
import theano.tensor as T
from theano import function
from theano import function, shared
from theano.tests import unittest_tools as utt
from theano.tensor.nnet.ConvTransp3D import convTransp3D
from theano.tensor.nnet.ConvGrad3D import convGrad3D
from theano.tensor.nnet.Conv3D import conv3D
import numpy as N
import copy
from scipy import sparse
from theano import shared
import theano.sparse
if theano.sparse.enable_sparse:
from scipy import sparse
from nose.plugins.skip import SkipTest
floatX = theano.config.floatX
......@@ -311,6 +313,8 @@ class TestConv3D(unittest.TestCase):
def test_c_against_sparse_mat_transp_mul(self):
#like test_c_against_mat_transp_mul but using a sparse matrix and a kernel that is smaller than the image
if not theano.sparse.enable_sparse:
raise SkipTest('Optional package sparse disabled')
batchSize = self.rng.randint(1,3)
filterWidth = self.rng.randint(1,8)
......
......@@ -7,6 +7,7 @@ from theano.gof.python25 import all
from theano import tensor
from theano.tests import unittest_tools as utt
from theano.misc.may_share_memory import may_share_memory
import theano.sparse
utt.seed_rng()
......@@ -445,7 +446,8 @@ def makeSharedTester(shared_constructor_,
topo_cst[0].op == theano.compile.function_module.deep_copy_op
# Test that we can take the grad.
if isinstance(x1_specify_shape.type, theano.sparse.SparseType):
if (theano.sparse.enable_sparse and
isinstance(x1_specify_shape.type, theano.sparse.SparseType)):
#SparseVariable don't support sum for now.
assert not hasattr(x1_specify_shape, 'sum')
else:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论