提交 0479c7b0 authored 作者: Pascal Lamblin's avatar Pascal Lamblin

In DebugMode, allow value of None if type is OK

Some types (like Generic) allow for a value of None. We should not consider it an error.
上级 49a5a90e
...@@ -1330,11 +1330,16 @@ class _Linker(gof.link.LocalLinker): ...@@ -1330,11 +1330,16 @@ class _Linker(gof.link.LocalLinker):
r_vals_initialized = [] r_vals_initialized = []
for r in storage_map: for r in storage_map:
if (r.owner is None): if (r.owner is None):
if (storage_map[r][0] is None):
raise Exception('Missing input', r)
if not r.type.is_valid_value(storage_map[r][0]): if not r.type.is_valid_value(storage_map[r][0]):
# None may be a valid input value (for instance,
# for a Generic object). We only want to raise
# an error if it is not valid.
if (storage_map[r][0] is None):
raise InvalidValueError(r, storage_map[r][0],
hint="Graph Input '%s' is missing" % str(r))
raise InvalidValueError(r, storage_map[r][0], raise InvalidValueError(r, storage_map[r][0],
hint="Graph Input '%s' is missing" % str(r)) hint=("Graph Input '%s' has invalid value "
"%s" % (r, storage_map[r][0])))
r_vals[r] = storage_map[r][0] r_vals[r] = storage_map[r][0]
storage_map[r][0] = None storage_map[r][0] = None
r_vals_initialized.append(r) r_vals_initialized.append(r)
...@@ -1577,7 +1582,8 @@ class _Linker(gof.link.LocalLinker): ...@@ -1577,7 +1582,8 @@ class _Linker(gof.link.LocalLinker):
#print storage_map #print storage_map
for r in storage_map: for r in storage_map:
if (r.owner is None): if (r.owner is None):
assert storage_map[r][0] is not None if not r.type.is_valid_value(None):
assert storage_map[r][0] is not None
############### ###############
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论