提交 4c7e7a54 authored 作者: Frederic's avatar Frederic

Work around python 3.4 2to3 conversion bug.

上级 48f4b192
......@@ -1411,6 +1411,10 @@ class Assert(T.Op):
return [input_shapes[0]]
assert_ = Assert()
#Unittest.assert_ is a deprecated name for assertTrue.
#2to3 convert theano.tensor.opt.assert_ to theano.tensor.opt.assertTrue
#So I define a new name as a work around.
assert_op = assert_
@register_specialize
......
......@@ -2789,7 +2789,7 @@ class test_assert(utt.InferShapeTester):
def test0(self):
x = T.scalar()
y = T.scalar()
f = theano.function([x, y], theano.tensor.opt.assert_(x, T.eq(x, y)))
f = theano.function([x, y], theano.tensor.opt.assert_op(x, T.eq(x, y)))
f(1, 1)
self.assertRaises(AssertionError, f, 1, 0)
......@@ -2801,7 +2801,7 @@ class test_assert(utt.InferShapeTester):
mode = compile.mode.get_mode(mode)
x = T.scalar()
f = theano.function([x], theano.tensor.opt.assert_(x, 1), mode=mode)
f = theano.function([x], theano.tensor.opt.assert_op(x, 1), mode=mode)
assert f(1) == 1
assert f(5) == 5
topo = f.maker.fgraph.toposort()
......@@ -2817,7 +2817,7 @@ class test_assert(utt.InferShapeTester):
x = T.scalar()
y = T.scalar()
f = theano.function([x, y], theano.tensor.opt.assert_(x, y, 1),
f = theano.function([x, y], theano.tensor.opt.assert_op(x, y, 1),
mode=mode)
assert f(1, 1) == 1
assert f(5, 1) == 5
......@@ -2835,7 +2835,7 @@ class test_assert(utt.InferShapeTester):
x = T.scalar()
y = T.scalar()
f = theano.function([x, y], theano.tensor.opt.assert_(x, y, 0),
f = theano.function([x, y], theano.tensor.opt.assert_op(x, y, 0),
mode=mode)
self.assertRaises(AssertionError, f, 1, 0)
topo = f.maker.fgraph.toposort()
......@@ -2849,14 +2849,14 @@ class test_assert(utt.InferShapeTester):
bdscal = dscalar()
adscal_val = numpy.random.rand()
bdscal_val = numpy.random.rand() + 1
out = theano.tensor.opt.assert_(adscal, bdscal)
out = theano.tensor.opt.assert_op(adscal, bdscal)
self._compile_and_check([adscal, bdscal], [out],
[adscal_val, bdscal_val], Assert)
admat = dmatrix()
admat_val = numpy.random.rand(3, 4)
adscal_val += 1
out = theano.tensor.opt.assert_(admat, adscal, bdscal)
out = theano.tensor.opt.assert_op(admat, adscal, bdscal)
self._compile_and_check([admat, adscal, bdscal], [out],
[admat_val, adscal_val, bdscal_val], Assert)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论