Skip to content

Commit 7e9e459

Browse files
committed
Add informative error if user tries to use Aesara function with PyTensor variables
1 parent 5b6c804 commit 7e9e459

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

pymc/pytensorf.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,23 @@
9292
]
9393

9494

95+
# Temporarily add an Aesara dispatch for PyTensor TensorVariable to inform users
96+
# of incorrect mixing of libraries
97+
try:
98+
from aesara.tensor import _as_tensor_variable as _as_tensor_variable_aesara
99+
100+
@_as_tensor_variable_aesara.register(TensorVariable)
101+
def raise_informative_error(*args, **kwargs):
102+
raise TypeError(
103+
"You are calling an Aesara function with PyTensor variables.\n"
104+
"Starting with PyMC 5.0, Aesara was replaced by PyTensor (see https://www.pymc.io/blog/pytensor_announcement.html).\n"
105+
"Replace your import of aesara.tensor with pytensor.tensor.",
106+
)
107+
108+
except ImportError:
109+
pass
110+
111+
95112
def convert_observed_data(data):
96113
"""Convert user provided dataset to accepted formats."""
97114

0 commit comments

Comments
 (0)