提交 cbc51446 authored 作者: Ian Goodfellow's avatar Ian Goodfellow

fixed some assertRaises(TypeError)s

上级 ca3529d2
......@@ -41,7 +41,7 @@ from theano.gof.python25 import any, all
from theano.gof.opt import Optimizer
from theano.gof import InconsistencyError, toolbox
from basic import get_scalar_constant_value
from basic import get_scalar_constant_value, NotScalarConstantError
from theano.tensor.opt import register_uncanonicalize
from theano import scalar as scal
......@@ -65,7 +65,7 @@ class MaxAndArgmaxOptimizer(Optimizer):
if len(node.outputs[1].clients)==0:
try:
axis=get_scalar_constant_value(node.inputs[1])
except (ValueError, TypeError), e:
except NotScalarConstantError:
return False
new = CAReduce(scal.maximum,axis)(node.inputs[0])
......
......@@ -6184,9 +6184,9 @@ class T_get_scalar_constant_value(unittest.TestCase):
# scalars.
v = tensor.ivector()
a = tensor.stack(v, 2, 3)
self.assertRaises(TypeError, get_scalar_constant_value, a[0])
self.assertRaises(TypeError, get_scalar_constant_value, a[1])
self.assertRaises(TypeError, get_scalar_constant_value, a[2])
self.assertRaises(tensor.NotScalarConstantError, get_scalar_constant_value, a[0])
self.assertRaises(tensor.NotScalarConstantError, get_scalar_constant_value, a[1])
self.assertRaises(tensor.NotScalarConstantError, get_scalar_constant_value, a[2])
# Test the case SubTensor(Shape(v)) when the dimensions
# is broadcastable.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论