提交 842d3bcd authored 作者: Brandon T. Willard's avatar Brandon T. Willard 提交者: Brandon T. Willard

Remove Type.validity_hint

上级 cf9d71bb
......@@ -1174,7 +1174,7 @@ def _check_preallocated_output(
r,
storage_map[r][0],
hint=thunk_name,
specific_hint=r.type.value_validity_msg(storage_map[r][0]),
specific_hint=validity_hint(r.type, storage_map[r][0]),
)
_check_inputs(
......@@ -1214,6 +1214,14 @@ def _check_preallocated_output(
fn.maker.mode = backup_mode
def validity_hint(type, x):
try:
type.filter(x, strict=True)
except Exception as e:
return str(e)
return "value is valid"
class _FunctionGraphEvent:
"""
A record of an event in the life of an FunctionGraph.
......@@ -1756,7 +1764,7 @@ class _Linker(LocalLinker):
# check output values for type-correctness
for r in node.outputs:
if not r.type.is_valid_value(storage_map[r][0]):
hint2 = r.type.value_validity_msg(storage_map[r][0])
hint2 = validity_hint(r.type, storage_map[r][0])
raise InvalidValueError(
r,
storage_map[r][0],
......
......@@ -156,10 +156,6 @@ class Type(MetaObject):
except (TypeError, ValueError):
return False
def value_validity_msg(self, data: D) -> Text:
"""Return a message explaining the output of `Type.is_valid_value`."""
return "none"
def make_variable(self, name: Optional[Text] = None) -> Variable:
"""Return a new `Variable` instance of this `Type`.
......
......@@ -246,13 +246,6 @@ class TensorType(CType):
f"You can try to manually convert {other} into a {self}."
)
def value_validity_msg(self, a):
try:
self.filter(a, strict=True)
except Exception as e:
return str(e)
return "value is valid"
def dtype_specs(self):
"""
Return a tuple (python type, c type, numpy typenum) that corresponds
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论