提交 b7a21266 authored 作者: Frédéric Bastien's avatar Frédéric Bastien

Merge pull request #1616 from nouiz/err_msg

Better error message for theano.tensor.{all,any}({True,False})
......@@ -44,7 +44,7 @@ def test_inter_process_cache():
x, y = theano.tensor.dvectors('xy')
f = theano.function([x, y], [MyOp()(x), MyOp()(y)])
f(numpy.arange(60), numpy.arange(60))
if theano.config.mode == 'FAST_COMPILE':
if theano.config.mode == 'FAST_COMPILE' or theano.config.cxx == "":
assert MyOp.nb_called == 0
else:
assert MyOp.nb_called == 1
......@@ -53,7 +53,7 @@ def test_inter_process_cache():
x, y = theano.tensor.dvectors('xy')
f = theano.function([x, y], [MyOp()(x), MyOp()(y)])
f(numpy.arange(60), numpy.arange(60))
if theano.config.mode == 'FAST_COMPILE':
if theano.config.mode == 'FAST_COMPILE' or theano.config.cxx == "":
assert MyOp.nb_called == 0
else:
assert MyOp.nb_called == 1
......@@ -110,7 +110,10 @@ def test_ifelse():
# We need lazy to end up being True for this test.
if theano.config.vm.lazy in [True, None]:
lazys = [True, None]
for cloop in [True, False]:
cloops = [True, False]
if theano.config.cxx == "":
cloops = [False]
for cloop in cloops:
for lazy in lazys:
linker = theano.gof.vm.VM_Linker(use_cloop=cloop, lazy=lazy)
f = function([a, b, c], ifelse(a, notimpl(b), c),
......
......@@ -1606,6 +1606,7 @@ class All(CAReduce):
return "All{%s}" % ", ".join(map(str, self.axis))
def make_node(self, input):
input = as_tensor_variable(input)
if input.dtype not in ["int8", "uint8"]:
input = theano.tensor.neq(input, 0)
ret = super(All, self).make_node(input)
......@@ -1631,6 +1632,7 @@ class Any(CAReduce):
return "Any{%s}" % ", ".join(map(str, self.axis))
def make_node(self, input):
input = as_tensor_variable(input)
if input.dtype not in ["int8", "uint8"]:
input = theano.tensor.neq(input, 0)
ret = super(Any, self).make_node(input)
......
import time
from nose.plugins.skip import SkipTest
import numpy
import theano
import theano.tensor as T
from theano.tests import unittest_tools as utt
from theano.tensor.nnet import conv
from theano.tensor.basic import _allclose, NotScalarConstantError
......@@ -18,6 +18,8 @@ class TestConv2D(utt.InferShapeTester):
self.input.name = 'default_V'
self.filters = T.dtensor4('filters')
self.filters.name = 'default_filters'
if not conv.imported_scipy_signal and theano.config.cxx == "":
raise SkipTest("conv2d tests need SciPy or a c++ compiler")
def validate(self, image_shape, filter_shape,
border_mode='valid', subsample=(1, 1),
......
import time
from nose.plugins.skip import SkipTest
import numpy
from scipy import ndimage
try:
from scipy import ndimage
except ImportError:
ndimage = None
import theano
from theano.tensor.nnet.conv3d2d import *
import theano.tests.unittest_tools as utt
......@@ -67,6 +72,8 @@ def pyconv3d(signals, filters):
def test_conv3d(mode=mode_without_gpu, shared=theano.tensor._shared):
if ndimage is None:
raise SkipTest("conv3d2d tests need SciPy")
Ns, Ts, C, Hs, Ws = 3, 10, 3, 32, 32
Nf, Tf, C, Hf, Wf = 32, 5 , 3, 5 , 5
......
......@@ -3140,6 +3140,8 @@ class T_local_erf(unittest.TestCase):
self.mode = theano.compile.mode.get_default_mode().including(
'canonicalize', 'fast_run').excluding('gpu', 'fusion')
self.mode._optimizer.position_cutoff = 1.50001
if theano.config.cxx == '' and not theano.scalar.basic_scipy.imported_scipy_special:
raise SkipTest("erf need a c++ compiler or scipy")
def test_local_one_plus_erf(self):
val = numpy.asarray([-30, -3, -2, -1, 0, 1, 2, 3, 30],
......@@ -3237,6 +3239,8 @@ class T_local_erfc(unittest.TestCase):
'canonicalize').including('fast_run').excluding('gpu')
self.mode = self.mode_fusion.excluding('fusion')
self.mode._optimizer.position_cutoff = 1.50001
if theano.config.cxx == '' and not theano.scalar.basic_scipy.imported_scipy_special:
raise SkipTest("erfc need a c++ compiler or scipy")
def test_local_one_minus_erfc(self):
""" test opt: 1-erfc(x) => erf(x) and -erfc(x)+1 => erf(x)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论