提交 c5baab47 authored 作者: Frederic's avatar Frederic

small test fix when scipy is not available.

上级 0b6e8f30
...@@ -198,17 +198,25 @@ def rebuild_collect_shared(outputs, ...@@ -198,17 +198,25 @@ def rebuild_collect_shared(outputs,
(store_into, update_d[store_into])) (store_into, update_d[store_into]))
# filter_variable ensure smooth conversion of cpu/gpu Types # filter_variable ensure smooth conversion of cpu/gpu Types
update_val = store_into.type.filter_variable(update_val) try:
if update_val.type != store_into.type: update_val = store_into.type.filter_variable(update_val)
err_msg = ('an update must have the same type as the ' except TypeError, e:
'original shared variable(dest, dest.type, ' err_msg = ('An update must have the same type as the'
'update_val, update_val.type)') ' original shared variable (shared_var=%s,'
err_arg = (store_into, ' shared_var.type=%s,'
store_into.type, ' update_val=%s, update_val.type=%s).' % (
update_val, store_into,
update_val.type) store_into.type,
update_val,
raise TypeError(err_msg, err_arg) update_val.type))
err_sug = ('If the difference is related to the broadcast pattern,'
' you can call the'
' tensor.unbroadcast(var, axis_to_unbroadcast[, ...])'
' function to remove broadcastable dimensions.')
raise TypeError(err_msg, err_sug)
assert update_val.type == store_into.type
update_d[store_into] = update_val update_d[store_into] = update_val
update_expr.append((store_into, update_val)) update_expr.append((store_into, update_val))
......
from nose.plugins.skip import SkipTest
import numpy import numpy
from theano import tensor, function from theano import tensor, function
from theano.tests import unittest_tools as utt from theano.tests import unittest_tools as utt
from theano.sandbox.linalg.kron import Kron, kron from theano.sandbox.linalg.kron import Kron, kron
...@@ -9,6 +11,9 @@ try: ...@@ -9,6 +11,9 @@ try:
except ImportError: except ImportError:
imported_scipy = False imported_scipy = False
if not imported_scipy:
raise SkipTest('Kron Op need the scipy package to be installed')
class TestKron(utt.InferShapeTester): class TestKron(utt.InferShapeTester):
...@@ -20,8 +25,6 @@ class TestKron(utt.InferShapeTester): ...@@ -20,8 +25,6 @@ class TestKron(utt.InferShapeTester):
self.op = kron self.op = kron
def test_perform(self): def test_perform(self):
assert imported_scipy, (
"Scipy not available. Scipy is needed for TestKron")
x = tensor.dmatrix() x = tensor.dmatrix()
y = tensor.dmatrix() y = tensor.dmatrix()
f = function([x, y], kron(x, y)) f = function([x, y], kron(x, y))
......
from nose.plugins.skip import SkipTest
import numpy import numpy
try: try:
import scipy.sparse as sp import scipy.sparse as sp
......
from nose.plugins.skip import SkipTest
import numpy import numpy
import theano.sparse import theano.sparse
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论