提交 1753068c authored 作者: Razvan Pascanu's avatar Razvan Pascanu

Added fix suggested by Pascal for the tests when dealing with the exception…

Added fix suggested by Pascal for the tests when dealing with the exception thrown by Subtensor (e_invalid)
上级 d98a89d3
......@@ -2319,7 +2319,10 @@ class Subtensor(Op):
idx_list = list(self.idx_list)
if len(idx_list) > x.type.ndim:
raise ValueError(Subtensor.e_invalid%(len(idx_list), x.type.ndim))
exception = ValueError(Subtensor.e_invalid%(len(idx_list),
x.type.ndim))
exception.subtensor_invalid = True
raise exception
#infer the broadcasting pattern
padded = idx_list + [slice(0,sys.maxint,1)] * (x.type.ndim - len(idx_list))
......@@ -2598,7 +2601,10 @@ class IncSubtensor(Op):
idx_list = list(self.idx_list)
if len(idx_list) > x.type.ndim:
raise ValueError(Subtensor.e_invalid%(len(idx_list), x.type.ndim))
exception = ValueError(Subtensor.e_invalid%(len(idx_list),
x.type.ndim))
exception.subtensor_invalid = True
raise exception
#infer the broadcasting pattern
padded = idx_list + [slice(0,sys.maxint,1)] * (x.type.ndim - len(idx_list))
......
......@@ -1304,7 +1304,7 @@ class T_subtensor(unittest.TestCase):
try:
t = n[0]
except ValueError, e:
self.failUnless(e[0] is Subtensor.e_invalid)
self.failUnless(hasattr(e,'subtensor_invalid'))
return
self.fail()
......@@ -1356,7 +1356,7 @@ class T_subtensor(unittest.TestCase):
try:
t = n[0,0]
except ValueError, e:
self.failUnless(e[0] is Subtensor.e_invalid)
self.failUnless(hasattr(e,'subtensor_invalid'))
return
self.fail()
def test1_ok_elem(self):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论