提交 8625e03d authored 作者: Olivier Delalleau's avatar Olivier Delalleau

Fixed detection of the presence of givens/updates

Since they can be dictionaries, their emptiness shouldn't be checked by comparing them to a list.
上级 6e5ad5af
...@@ -186,8 +186,8 @@ def function(inputs, outputs=None, mode=None, updates=None, givens=None, ...@@ -186,8 +186,8 @@ def function(inputs, outputs=None, mode=None, updates=None, givens=None,
# compute some features of the arguments: # compute some features of the arguments:
uses_In = any([isinstance(i, In) for i in inputs]) # N.B. the square brackets are ncessary uses_In = any([isinstance(i, In) for i in inputs]) # N.B. the square brackets are ncessary
uses_tuple = any([isinstance(i, (list, tuple)) for i in inputs]) # N.B. the square brackets are ncessary uses_tuple = any([isinstance(i, (list, tuple)) for i in inputs]) # N.B. the square brackets are ncessary
uses_updates = (updates != []) uses_updates = bool(updates)
uses_givens = (givens != []) uses_givens = bool(givens)
# See if we have any mutable / borrow inputs # See if we have any mutable / borrow inputs
check_for_aliased_inputs = False check_for_aliased_inputs = False
...@@ -201,7 +201,9 @@ def function(inputs, outputs=None, mode=None, updates=None, givens=None, ...@@ -201,7 +201,9 @@ def function(inputs, outputs=None, mode=None, updates=None, givens=None,
if profile: if profile:
raise NotImplementedError('profiling not supported in old-style function') raise NotImplementedError('profiling not supported in old-style function')
if uses_updates or uses_givens: if uses_updates or uses_givens:
raise NotImplementedError("In() instances and tuple inputs triggers the old semantics, which disallow using updates and givens") raise NotImplementedError(
"In() instances and tuple inputs trigger the old "
"semantics, which disallow using updates and givens")
fn = orig_function(inputs, outputs, fn = orig_function(inputs, outputs,
mode=mode, mode=mode,
accept_inplace=accept_inplace, name=name) accept_inplace=accept_inplace, name=name)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论