提交 0899c470 authored 作者: Olivier Delalleau's avatar Olivier Delalleau

Replaced warning by exception

Since mutable=True is incompatible with borrow=False, it is better to raise an exception to make sure it's being noticed.
上级 130b5abc
......@@ -208,17 +208,14 @@ class In(SymbolicInput):
# mutable implies the output can be both aliased to the input and that
# the input can be destroyed. borrow simply implies the output can be
# aliased to the input. Thus mutable=True should require borrow=True.
# Raise warning when borrow is explicitely set to False with
# mutable=True.
if mutable:
if not self.borrow:
_logger.warning("Symbolic input for variable %s (name=%s) has "
if mutable and not self.borrow:
raise AssertionError(
"Symbolic input for variable %s (name=%s) has "
"flags mutable=True, borrow=False. This combination is "
"incompatible since mutable=True implies that the "
"input variable may be both aliased (borrow=True) and "
"over-written. We set borrow=True and continue.",
"overwritten.",
variable, name)
self.borrow = True
if implicit is None:
implicit = (isinstance(value, gof.Container) or
......
......@@ -298,17 +298,15 @@ class Param(object):
# mutable implies the output can be both aliased to the input and that
# the input can be destroyed. borrow simply implies the output can be
# aliased to the input. Thus mutable=True should require borrow=True.
# Raise warning when borrow is explicitly set to False with
# mutable=True.
if mutable:
if not self.borrow:
_logger.warning("Symbolic input for variable %s (name=%s) has "
"flags mutable=True, borrow=False. This combination is "
"incompatible since mutable=True implies that the "
"input variable may be both aliased (borrow=True) and "
"over-written. We set borrow=True and continue.",
variable, name)
self.borrow = True
if self.mutable and not self.borrow:
raise AssertionError(
"Symbolic input for variable %s (name=%s) has "
"flags mutable=True, borrow=False. This combination is "
"incompatible since mutable=True implies that the "
"input variable may be both aliased (borrow=True) and "
"overwritten.",
variable, name)
self.strict = strict
self.allow_downcast = allow_downcast
self.implicit = implicit
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论