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

remove more deprecated modules

上级 e0589482
import warnings
warnings.warn(
"The module `pytensor.tensor.basic_opt` is deprecated; use `pytensor.tensor.rewriting.basic` instead.",
DeprecationWarning,
stacklevel=2,
)
from pytensor.tensor.rewriting.basic import * # noqa: F401 E402 F403
from pytensor.tensor.rewriting.elemwise import * # noqa: F401 E402 F403
from pytensor.tensor.rewriting.extra_ops import * # noqa: F401 E402 F403
from pytensor.tensor.rewriting.shape import * # noqa: F401 E402 F403
import warnings
warnings.warn(
"The module `pytensor.tensor.math_opt` is deprecated; use `pytensor.tensor.rewriting.math` instead.",
DeprecationWarning,
stacklevel=2,
)
from pytensor.tensor.rewriting.math import * # noqa: F401 E402 F403
import warnings
warnings.warn(
"The module `pytensor.tensor.opt_uncanonicalize` is deprecated; use `pytensor.tensor.rewriting.uncanonicalize` instead.",
DeprecationWarning,
stacklevel=2,
)
from pytensor.tensor.rewriting.uncanonicalize import * # noqa: F401 E402 F403
import warnings
warnings.warn(
"The module `pytensor.tensor.subtensor_opt` is deprecated; use `pytensor.tensor.rewriting.subtensor` instead.",
DeprecationWarning,
stacklevel=2,
)
from pytensor.tensor.rewriting.subtensor import * # noqa: F401 E402 F403
import sys
import pytest import pytest
from pytensor.graph.rewriting.basic import GraphRewriter, SequentialGraphRewriter from pytensor.graph.rewriting.basic import GraphRewriter, SequentialGraphRewriter
...@@ -86,17 +84,3 @@ class TestDB: ...@@ -86,17 +84,3 @@ class TestDB:
def test_ProxyDB(self): def test_ProxyDB(self):
with pytest.raises(TypeError, match=r"`db` must be.*"): with pytest.raises(TypeError, match=r"`db` must be.*"):
ProxyDB(object()) ProxyDB(object())
def test_deprecations():
"""Make sure we can import deprecated classes from current and deprecated modules."""
with pytest.deprecated_call():
from pytensor.graph.rewriting.db import OptimizationDatabase # noqa: F401 F811
with pytest.deprecated_call():
from pytensor.graph.optdb import OptimizationDatabase # noqa: F401 F811
del sys.modules["pytensor.graph.optdb"]
with pytest.deprecated_call():
from pytensor.graph.optdb import RewriteDatabase # noqa: F401
...@@ -165,9 +165,3 @@ def test_KanrenRelationSub_dot(): ...@@ -165,9 +165,3 @@ def test_KanrenRelationSub_dot():
assert expr_opt.owner.inputs[1].owner.op == at.add assert expr_opt.owner.inputs[1].owner.op == at.add
assert isinstance(expr_opt.owner.inputs[1].owner.inputs[0].owner.op, Dot) assert isinstance(expr_opt.owner.inputs[1].owner.inputs[0].owner.op, Dot)
assert isinstance(expr_opt.owner.inputs[1].owner.inputs[1].owner.op, Dot) assert isinstance(expr_opt.owner.inputs[1].owner.inputs[1].owner.op, Dot)
def test_deprecations():
"""Make sure we can import deprecated classes from current and deprecated modules."""
with pytest.deprecated_call():
from pytensor.graph.kanren import KanrenRelationSub # noqa: F401 F811
...@@ -350,9 +350,3 @@ def test_convert_strs_to_vars(): ...@@ -350,9 +350,3 @@ def test_convert_strs_to_vars():
res = convert_strs_to_vars((val,)) res = convert_strs_to_vars((val,))
assert isinstance(res[0], Constant) assert isinstance(res[0], Constant)
assert np.array_equal(res[0].data, val) assert np.array_equal(res[0].data, val)
def test_deprecations():
"""Make sure we can import deprecated classes from current and deprecated modules."""
with pytest.deprecated_call():
from pytensor.graph.unify import eval_if_etuple # noqa: F401 F811
import sys
import pytest
from pytensor.graph.fg import FunctionGraph from pytensor.graph.fg import FunctionGraph
from pytensor.graph.rewriting.basic import graph_rewriter from pytensor.graph.rewriting.basic import graph_rewriter
from pytensor.graph.rewriting.utils import is_same_graph, rewrite_graph from pytensor.graph.rewriting.utils import is_same_graph, rewrite_graph
...@@ -160,17 +156,3 @@ def test_rewrite_graph(): ...@@ -160,17 +156,3 @@ def test_rewrite_graph():
) )
assert x_rewritten.outputs[0] is y assert x_rewritten.outputs[0] is y
def test_deprecations():
"""Make sure we can import deprecated classes from current and deprecated modules."""
with pytest.deprecated_call():
from pytensor.graph.rewriting.utils import optimize_graph # noqa: F401 F811
with pytest.deprecated_call():
from pytensor.graph.opt_utils import optimize_graph # noqa: F401 F811
del sys.modules["pytensor.graph.opt_utils"]
with pytest.deprecated_call():
from pytensor.graph.opt_utils import rewrite_graph # noqa: F401
...@@ -1884,12 +1884,3 @@ class TestLocalElemwiseAlloc: ...@@ -1884,12 +1884,3 @@ class TestLocalElemwiseAlloc:
x_val = np.random.random((1, 5)).astype(self.dtype) x_val = np.random.random((1, 5)).astype(self.dtype)
exp_res = np.broadcast_to(x_val, (5, 5))[..., None] + y_val exp_res = np.broadcast_to(x_val, (5, 5))[..., None] + y_val
assert np.array_equal(func(y_val, x_val), exp_res) assert np.array_equal(func(y_val, x_val), exp_res)
def test_deprecations():
"""Make sure we can import from deprecated modules."""
with pytest.deprecated_call():
from pytensor.tensor.basic_opt import register_useless # noqa: F401 F811
with pytest.deprecated_call():
from pytensor.tensor.rewriting.basic import ShapeFeature # noqa: F401
...@@ -4625,12 +4625,6 @@ def test_local_useless_conj(): ...@@ -4625,12 +4625,6 @@ def test_local_useless_conj():
assert any(node.op == _conj for node in f.maker.fgraph.apply_nodes) assert any(node.op == _conj for node in f.maker.fgraph.apply_nodes)
def test_deprecations():
"""Make sure we can import from deprecated modules."""
with pytest.deprecated_call():
from pytensor.tensor.math_opt import AlgebraicCanonizer # noqa: F401 F811
def test_local_sub_neg_to_add(): def test_local_sub_neg_to_add():
x = scalar("x") x = scalar("x")
y = vector("y") y = vector("y")
......
...@@ -2166,14 +2166,6 @@ def test_local_join_subtensors(axis, slices_fn, expected_nodes): ...@@ -2166,14 +2166,6 @@ def test_local_join_subtensors(axis, slices_fn, expected_nodes):
np.testing.assert_array_equal(f(x_val, stop_val), f_val) np.testing.assert_array_equal(f(x_val, stop_val), f_val)
def test_deprecations():
"""Make sure we can import from deprecated modules."""
with pytest.deprecated_call():
from pytensor.tensor.subtensor_opt import ( # noqa: F401 F811
get_advsubtensor_axis,
)
def test_local_uint_constant_indices(): def test_local_uint_constant_indices():
mode = get_default_mode().including("specialize", "local_uint_constant_indices") mode = get_default_mode().including("specialize", "local_uint_constant_indices")
rng = np.random.default_rng(20900) rng = np.random.default_rng(20900)
......
import numpy as np import numpy as np
import pytest
import pytensor import pytensor
import pytensor.tensor as at import pytensor.tensor as at
...@@ -219,11 +218,3 @@ def test_local_dimshuffle_subtensor(): ...@@ -219,11 +218,3 @@ def test_local_dimshuffle_subtensor():
assert x[:, :, 0:3, ::-1].dimshuffle(0, 2, 3).eval( assert x[:, :, 0:3, ::-1].dimshuffle(0, 2, 3).eval(
{x: np.ones((5, 1, 6, 7))} {x: np.ones((5, 1, 6, 7))}
).shape == (5, 3, 7) ).shape == (5, 3, 7)
def test_deprecations():
"""Make sure we can import from deprecated modules."""
with pytest.deprecated_call():
from pytensor.tensor.opt_uncanonicalize import ( # noqa: F401 F811
local_reshape_dimshuffle,
)
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论