提交 8e34b4bb authored 作者: Frederic Bastien's avatar Frederic Bastien

added better error msg when we pass to many arguments to theano fct.

上级 d7e13316
...@@ -443,6 +443,9 @@ class Function(object): ...@@ -443,6 +443,9 @@ class Function(object):
for c in self.input_storage: for c in self.input_storage:
c.provided = 0 c.provided = 0
if len(args)+len(kwargs)>len(self.input_storage):
raise TypeError("Too many parameter passed to theano function")
# Set positional arguments # Set positional arguments
i = 0 i = 0
for arg in args: for arg in args:
......
...@@ -41,6 +41,11 @@ class T_function(unittest.TestCase): ...@@ -41,6 +41,11 @@ class T_function(unittest.TestCase):
fn = function([], []) #ok fn = function([], []) #ok
self.failUnless(fn() == []) self.failUnless(fn() == [])
def test_extra_inputs(self):
x,s = T.scalars('xs')
fn = function([x], [x])
self.failUnlessRaises(TypeError,fn,1,2)
def test_missing_inputs(self): def test_missing_inputs(self):
MissingInputException = TypeError MissingInputException = TypeError
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论