Skip to content

Commit 864c66f

Browse files
committed
deprecate var and add test
1 parent 9301556 commit 864c66f

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

pytensor/tensor/var.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import warnings
2+
3+
4+
from pytensor.tensor.variable import * # noqa
5+
6+
warnings.warn(
7+
"The module 'pytensor.tensor.var' has been deprecated. "
8+
"Use 'pytensor.tensor.variable' instead.",
9+
category=DeprecationWarning,
10+
stacklevel=2,
11+
)

tests/tensor/test_variable.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,3 +405,15 @@ def test_take(self):
405405
assert_array_equal(X.take(indices, 1).eval({X: x}), x.take(indices, 1))
406406
# Test equivalent advanced indexing
407407
assert_array_equal(X[:, indices].eval({X: x}), x[:, indices])
408+
409+
410+
def test_deprecated_import():
411+
with pytest.warns(
412+
DeprecationWarning,
413+
match="The module 'pytensor.tensor.var' has been deprecated.",
414+
):
415+
import pytensor.tensor.var as _var
416+
417+
# Make sure the deprecated import provides access to 'variable' module
418+
assert hasattr(_var, "TensorVariable")
419+
assert hasattr(_var, "TensorConstant")

0 commit comments

Comments
 (0)