提交 a77fc07a authored 作者: Maxim Kochurov's avatar Maxim Kochurov 提交者: Maxim Kochurov

remove outdated deprecations from pytensor/graph/rewriting/utils.py

上级 ba0c51c0
import copy
import warnings
from typing import TYPE_CHECKING, Generator, Optional, Sequence, Union, cast
import pytensor
......@@ -23,7 +22,6 @@ def rewrite_graph(
include: Sequence[str] = ("canonicalize",),
custom_rewrite: Optional["GraphRewriter"] = None,
clone: bool = False,
custom_opt: Optional["GraphRewriter"] = None,
**kwargs,
) -> Union[Variable, Sequence[Variable], FunctionGraph]:
"""Easily apply rewrites to a graph.
......@@ -62,14 +60,6 @@ def rewrite_graph(
query_rewrites = optdb.query(RewriteDatabaseQuery(include=include, **kwargs))
_ = query_rewrites.rewrite(fgraph)
if custom_opt is not None:
warnings.warn(
"`custom_opt` is deprecated; use `custom_rewrite` instead.",
DeprecationWarning,
stacklevel=2,
)
custom_rewrite = custom_opt
if custom_rewrite:
custom_rewrite.rewrite(fgraph)
......@@ -248,28 +238,3 @@ def get_clients_at_depth(
else:
assert var.owner is not None
yield var.owner
DEPRECATED_NAMES = [
(
"optimize_graph",
"`optimize_graph` is deprecated: use `rewrite_graph` instead.",
rewrite_graph,
),
]
def __getattr__(name):
"""Intercept module-level attribute access of deprecated symbols.
Adapted from https://stackoverflow.com/a/55139609/3006474.
"""
from warnings import warn
for old_name, msg, old_object in DEPRECATED_NAMES:
if name == old_name:
warn(msg, DeprecationWarning, stacklevel=2)
return old_object
raise AttributeError(f"module {__name__} has no attribute {name}")
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论