提交 10bb77bf authored 作者: Brandon T. Willard's avatar Brandon T. Willard 提交者: Brandon T. Willard

Fix type exceptions

上级 9b787864
...@@ -64,7 +64,7 @@ def alias_root(v): ...@@ -64,7 +64,7 @@ def alias_root(v):
v_views = vmap.get(outpos, []) + dmap.get(outpos, []) v_views = vmap.get(outpos, []) + dmap.get(outpos, [])
if len(v_views) > 1: if len(v_views) > 1:
raise NotImplementedError( raise NotImplementedError(
str(v) + " is a view/destroyed version of more then one inputs. " f"{v} is a view/destroyed version of more then one inputs. "
"Currently, we only support the case where an output is a view or " "Currently, we only support the case where an output is a view or "
"a destroyed version of one input." "a destroyed version of one input."
) )
...@@ -192,9 +192,7 @@ def std_fgraph(input_specs, output_specs, accept_inplace=False): ...@@ -192,9 +192,7 @@ def std_fgraph(input_specs, output_specs, accept_inplace=False):
for node in fgraph.apply_nodes: for node in fgraph.apply_nodes:
if node.op.destroy_map: if node.op.destroy_map:
if not accept_inplace: if not accept_inplace:
raise TypeError( raise TypeError(f"Graph must not contain inplace operations: {node}")
"Graph must not contain inplace operations", node, node.op
)
else: else:
fgraph.attach_feature(DestroyHandler()) fgraph.attach_feature(DestroyHandler())
break break
...@@ -1333,7 +1331,9 @@ class FunctionMaker: ...@@ -1333,7 +1331,9 @@ class FunctionMaker:
if len(input) == 2: if len(input) == 2:
return SymbolicInput(input[0], update=input[1]) return SymbolicInput(input[0], update=input[1])
else: else:
raise TypeError("Expected two elements in the list or tuple.", input) raise TypeError(
f"Expected two elements in the list or tuple; got {input}"
)
else: else:
raise TypeError( raise TypeError(
f"Unknown input type: {type(input)} ({input}), expected Variable " f"Unknown input type: {type(input)} ({input}), expected Variable "
...@@ -1748,10 +1748,9 @@ class FunctionMaker: ...@@ -1748,10 +1748,9 @@ class FunctionMaker:
raise UnusedInputError(msg % (inputs.index(i), i.variable, err_msg)) raise UnusedInputError(msg % (inputs.index(i), i.variable, err_msg))
else: else:
raise ValueError( raise ValueError(
"Invalid value for keyword " "Invalid value for keyword on_unused_input of aesara.function: "
"on_unused_input of aesara.function: " f"'{on_unused_input}'.\n"
"'%s'.\nValid values are 'raise', " "Valid values are 'raise', 'warn', and 'ignore'."
"'warn', and 'ignore'." % on_unused_input
) )
def create(self, input_storage=None, trustme=False, storage_map=None): def create(self, input_storage=None, trustme=False, storage_map=None):
...@@ -2016,7 +2015,7 @@ def convert_function_input(input): ...@@ -2016,7 +2015,7 @@ def convert_function_input(input):
if isinstance(input, SymbolicInput): if isinstance(input, SymbolicInput):
return input return input
elif isinstance(input, Constant): elif isinstance(input, Constant):
raise TypeError("A Constant instance is not a legal function input", input) raise TypeError(f"A Constant instance is not a legal function input: {input}")
elif isinstance(input, Variable): elif isinstance(input, Variable):
return In(input) return In(input)
elif isinstance(input, (list, tuple)): elif isinstance(input, (list, tuple)):
...@@ -2059,13 +2058,11 @@ def convert_function_input(input): ...@@ -2059,13 +2058,11 @@ def convert_function_input(input):
if not isinstance(variable, Variable): if not isinstance(variable, Variable):
raise TypeError( raise TypeError(
f"Unknown input type: {type(variable)}, expected Variable instance", f"Unknown input type: {type(variable)}, expected Variable instance"
variable,
) )
if update is not None and not isinstance(update, Variable): if update is not None and not isinstance(update, Variable):
raise TypeError( raise TypeError(
f"Unknown update type: {type(update)}, expected Variable instance", f"Unknown update type: {type(update)}, expected Variable instance"
update,
) )
if value is not None and isinstance(value, (Variable, SymbolicInput)): if value is not None and isinstance(value, (Variable, SymbolicInput)):
raise TypeError( raise TypeError(
...@@ -2076,7 +2073,7 @@ def convert_function_input(input): ...@@ -2076,7 +2073,7 @@ def convert_function_input(input):
return In(variable, name=name, value=value, update=update) return In(variable, name=name, value=value, update=update)
else: else:
raise TypeError( raise TypeError(
f"Unknown input type: {type(input)}, expected Variable instance", input f"Unknown input type: {type(input)}, expected Variable instance"
) )
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论