提交 b461908b authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Disable compute_test_value for test that expect errors.

上级 749a492d
......@@ -8,6 +8,7 @@ import theano.tensor as T
from theano.tensor.nnet.neighbours import images2neibs, neibs2images, Images2Neibs
from theano.tests import unittest_tools
from theano.configparser import change_flags
mode_without_gpu = theano.compile.mode.get_default_mode().excluding('gpu')
......@@ -140,6 +141,7 @@ class T_Images2Neibs(unittest_tools.InferShapeTester):
# print g()
# assert numpy.allclose(images.get_value(borrow=True), g())
@change_flags(compute_test_value='off')
def test_neibs_bad_shape(self):
shape = (2, 3, 10, 10)
for dtype in self.dtypes:
......@@ -287,6 +289,7 @@ class T_Images2Neibs(unittest_tools.InferShapeTester):
f_full = theano.function([], x_using_full, mode=self.mode)
unittest_tools.assert_allclose(f_valid(), f_full())
@change_flags(compute_test_value='off')
def test_neibs_bad_shape_wrap_centered(self):
shape = (2, 3, 10, 10)
......
......@@ -57,7 +57,7 @@ from theano.tensor import (
from theano.tests import unittest_tools as utt
from theano.tests.unittest_tools import attr
from theano.configparser import change_flags
imported_scipy_special = False
mode_no_scipy = get_default_mode()
......@@ -443,6 +443,7 @@ def makeTester(name, op, expected, checks=None, good=None, bad_build=None,
# instantiated on the following bad inputs: %s"
# % (self.op, testname, node, inputs))
@change_flags(compute_test_value='off')
def test_bad_runtime(self):
if skip:
raise SkipTest(skip)
......@@ -4383,14 +4384,15 @@ class T_Join_and_Split(unittest.TestCase):
for node in topo:
assert not isinstance(node.op, type(self.join_op))
# Test hide error
x1.set_value(get_mat(3, 4))
x2.set_value(get_mat(3, 4))
x3.set_value(get_mat(2, 5))
if not self.hide_error:
self.assertRaises(ValueError, f)
else:
f()
with change_flags(compute_test_value='off'):
# Test hide error
x1.set_value(get_mat(3, 4))
x2.set_value(get_mat(3, 4))
x3.set_value(get_mat(2, 5))
if not self.hide_error:
self.assertRaises(ValueError, f)
else:
f()
def test_rebroadcast(self):
# Regression test for a crash that used to happen when rebroadcasting.
......@@ -4432,6 +4434,7 @@ class T_Join_and_Split(unittest.TestCase):
assert np.allclose(o1, m.get_value(borrow=True))
assert np.allclose(o2, m.get_value(borrow=True)[4:])
@change_flags(compute_test_value='off')
def test_split_neg(self):
rng = np.random.RandomState(seed=utt.fetch_seed())
m = self.shared(rng.rand(4, 6).astype(self.floatX))
......@@ -7321,11 +7324,12 @@ class T_get_scalar_constant_value(unittest.TestCase):
a = opt.Assert()(c, c > 1)
assert get_scalar_constant_value(a) == 2
# condition is always False
a = opt.Assert()(c, c > 2)
self.assertRaises(
tensor.NotScalarConstantError,
get_scalar_constant_value, a)
with change_flags(compute_test_value='off'):
# condition is always False
a = opt.Assert()(c, c > 2)
self.assertRaises(
tensor.NotScalarConstantError,
get_scalar_constant_value, a)
# condition is not constant
a = opt.Assert()(c, c > x)
......
......@@ -6,11 +6,14 @@ import subprocess
import os
from theano.gof.sched import sort_schedule_fn
from theano.configparser import change_flags
mpi_scheduler = sort_schedule_fn(*mpi_cmps)
mpi_linker = theano.OpWiseCLinker(schedule=mpi_scheduler)
mpi_mode = theano.Mode(linker=mpi_linker)
@change_flags(compute_test_value='off')
def test_recv():
x = recv((10, 10), 'float64', 0, 11)
assert x.dtype == 'float64'
......@@ -29,6 +32,7 @@ def test_send():
assert sendnode.op.tag == 11
@change_flags(compute_test_value='off')
def test_can_make_function():
x = recv((5, 5), 'float32', 0, 11)
y = x+1
......@@ -61,6 +65,7 @@ def test_mpi_send_wait_cmp():
assert mpi_send_wait_cmp(waitnode, addnode) > 0 # wait happens last
@change_flags(compute_test_value='off')
def test_mpi_tag_ordering():
x = recv((2, 2), 'float32', 1, 12)
y = recv((2, 2), 'float32', 1, 11)
......
......@@ -63,6 +63,7 @@ from theano.tensor.elemwise import DimShuffle
from theano.tensor.type import values_eq_approx_remove_nan
from theano.tests import unittest_tools as utt
from theano.gof.opt import check_stack_trace, out2in
from theano.configparser import change_flags
from nose.plugins.attrib import attr
mode_opt = theano.config.mode
......@@ -3685,6 +3686,7 @@ class Test_local_canonicalize_alloc(unittest.TestCase):
def setUp(self):
self.rng = np.random.RandomState(utt.fetch_seed())
@change_flags(compute_test_value='off')
def test0(self):
x = shared(self.rng.randn(3, 7))
a = tensor.alloc(x, 6, 7)
......@@ -5602,7 +5604,7 @@ class T_local_opt_alloc(unittest.TestCase):
finally:
theano.config.warn_float64 = orig
@theano.configparser.change_flags(on_opt_error='raise')
@change_flags(on_opt_error='raise')
def test_sum_bool_upcast(self):
s = theano.tensor.lscalar()
a = theano.tensor.alloc(np.asarray(True, dtype='bool'), s, s)
......
......@@ -34,6 +34,7 @@ from theano.tensor.subtensor import (AdvancedIncSubtensor,
from theano.tensor.tests.test_basic import inplace_func, rand, randint_ranged
from theano.tests import unittest_tools as utt
from theano.tests.unittest_tools import attr
from theano.configparser import change_flags
if PY3:
def L(i):
......@@ -126,14 +127,10 @@ class T_subtensor(unittest.TestCase, utt.TestOptimizationMixin):
return
self.fail()
@change_flags(compute_test_value='off')
def test1_err_bounds(self):
n = self.shared(np.ones(3, dtype=self.dtype))
ctv_backup = config.compute_test_value
config.compute_test_value = 'off'
try:
t = n[7]
finally:
config.compute_test_value = ctv_backup
t = n[7]
self.assertTrue(isinstance(t.owner.op, Subtensor))
# Silence expected error messages
_logger = logging.getLogger('theano.gof.opt')
......@@ -223,26 +220,23 @@ class T_subtensor(unittest.TestCase, utt.TestOptimizationMixin):
self.assertTrue(tval.shape == (2,))
self.assertTrue((tval == [0.0, 2.0]).all())
@change_flags(compute_test_value='off')
def test2_err_bounds0(self):
n = self.shared(np.ones((2, 3), dtype=self.dtype) * 5)
ctv_backup = config.compute_test_value
config.compute_test_value = 'off'
try:
for idx in [(0, 4), (0, -4)]:
t = n[idx]
self.assertTrue(isinstance(t.owner.op, Subtensor))
# Silence expected warnings
_logger = logging.getLogger('theano.gof.opt')
oldlevel = _logger.level
_logger.setLevel(logging.CRITICAL)
try:
self.assertRaises(IndexError,
self.eval_output_and_check, [t])
finally:
_logger.setLevel(oldlevel)
finally:
config.compute_test_value = ctv_backup
for idx in [(0, 4), (0, -4)]:
t = n[idx]
self.assertTrue(isinstance(t.owner.op, Subtensor))
# Silence expected warnings
_logger = logging.getLogger('theano.gof.opt')
oldlevel = _logger.level
_logger.setLevel(logging.CRITICAL)
try:
self.assertRaises(IndexError,
self.eval_output_and_check, [t])
finally:
_logger.setLevel(oldlevel)
@change_flags(compute_test_value='off')
def test2_err_bounds1(self):
n = self.shared((np.ones((2, 3), dtype=self.dtype) * 5))
t = n[4:5, 3]
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论