提交 6721b880 authored 作者: Frederic's avatar Frederic

skip some tests when scipy isn't available.

上级 0fb7831a
...@@ -19,7 +19,7 @@ from theano.gof.python25 import all, any, product ...@@ -19,7 +19,7 @@ from theano.gof.python25 import all, any, product
from theano.tensor.basic import _allclose from theano.tensor.basic import _allclose
if not enable_sparse: if not enable_sparse:
raise SkipTest('Optional package sparse disabled') raise SkipTest('Optional package SciPy not installed')
from theano.sparse.basic import _is_dense, _is_sparse, _mtypes from theano.sparse.basic import _is_dense, _is_sparse, _mtypes
from theano.sparse.basic import _is_dense_variable, _is_sparse_variable from theano.sparse.basic import _is_dense_variable, _is_sparse_variable
......
import unittest import unittest
from nose.plugins.skip import SkipTest
import numpy import numpy
import theano import theano
...@@ -12,7 +13,12 @@ from theano.typed_list.basic import (GetItem, Insert, ...@@ -12,7 +13,12 @@ from theano.typed_list.basic import (GetItem, Insert,
Index, Count, Length) Index, Count, Length)
from theano import sparse from theano import sparse
from theano.tests import unittest_tools as utt from theano.tests import unittest_tools as utt
import scipy.sparse as sp # TODO, handle the case where scipy isn't installed.
try:
import scipy.sparse as sp
scipy_imported = True
except ImportError:
scipy_imported = False
#took from tensors/tests/test_basic.py #took from tensors/tests/test_basic.py
...@@ -435,6 +441,8 @@ class test_index(unittest.TestCase): ...@@ -435,6 +441,8 @@ class test_index(unittest.TestCase):
self.assertTrue(f([[x, y], [x, y, y]], [x, y]) == 0) self.assertTrue(f([[x, y], [x, y, y]], [x, y]) == 0)
def test_sparse(self): def test_sparse(self):
if not scipy_imported:
raise SkipTest('Optional package SciPy not installed')
mySymbolicSparseList = TypedListType(sparse.SparseType('csr', mySymbolicSparseList = TypedListType(sparse.SparseType('csr',
theano.config.floatX))() theano.config.floatX))()
mySymbolicSparse = sparse.csr_matrix() mySymbolicSparse = sparse.csr_matrix()
...@@ -499,6 +507,8 @@ class test_count(unittest.TestCase): ...@@ -499,6 +507,8 @@ class test_count(unittest.TestCase):
self.assertTrue(f([[x, y], [x, y, y]], [x, y]) == 1) self.assertTrue(f([[x, y], [x, y, y]], [x, y]) == 1)
def test_sparse(self): def test_sparse(self):
if not scipy_imported:
raise SkipTest('Optional package SciPy not installed')
mySymbolicSparseList = TypedListType(sparse.SparseType('csr', mySymbolicSparseList = TypedListType(sparse.SparseType('csr',
theano.config.floatX))() theano.config.floatX))()
mySymbolicSparse = sparse.csr_matrix() mySymbolicSparse = sparse.csr_matrix()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论