Skip to content

Commit 5a26eaf

Browse files
committed
Remove deprecated Model functionality
1 parent 5bc6801 commit 5a26eaf

File tree

2 files changed

+2
-39
lines changed

2 files changed

+2
-39
lines changed

pymc/model/core.py

+2-23
Original file line numberDiff line numberDiff line change
@@ -107,18 +107,10 @@ def __new__(cls, name, bases, dct, **kwargs):
107107

108108
def __enter__(self):
109109
self.__class__.context_class.get_contexts().append(self)
110-
# self._pytensor_config is set in Model.__new__
111-
self._config_context = None
112-
if hasattr(self, "_pytensor_config"):
113-
self._config_context = pytensor.config.change_flags(**self._pytensor_config)
114-
self._config_context.__enter__()
115110
return self
116111

117112
def __exit__(self, typ, value, traceback):
118113
self.__class__.context_class.get_contexts().pop()
119-
# self._pytensor_config is set in Model.__new__
120-
if self._config_context:
121-
self._config_context.__exit__(typ, value, traceback)
122114

123115
dct[__enter__.__name__] = __enter__
124116
dct[__exit__.__name__] = __exit__
@@ -485,13 +477,6 @@ def __new__(cls, *args, **kwargs):
485477
instance._parent = kwargs.get("model")
486478
else:
487479
instance._parent = cls.get_context(error_if_none=False)
488-
pytensor_config = kwargs.get("pytensor_config", {})
489-
if pytensor_config:
490-
warnings.warn(
491-
"pytensor_config is deprecated. Use pytensor.config or pytensor.config.change_flags context manager instead.",
492-
FutureWarning,
493-
)
494-
instance._pytensor_config = pytensor_config
495480
return instance
496481

497482
@staticmethod
@@ -507,10 +492,9 @@ def __init__(
507492
check_bounds=True,
508493
*,
509494
coords_mutable=None,
510-
pytensor_config=None,
511495
model=None,
512496
):
513-
del pytensor_config, model # used in __new__
497+
del model # used in __new__
514498
self.name = self._validate_name(name)
515499
self.check_bounds = check_bounds
516500

@@ -560,11 +544,6 @@ def __init__(
560544
functools.partial(str_for_model, formatting="latex"), self
561545
)
562546

563-
@property
564-
def model(self):
565-
warnings.warn("Model.model property is deprecated. Just use Model.", FutureWarning)
566-
return self
567-
568547
@property
569548
def parent(self):
570549
return self._parent
@@ -671,7 +650,7 @@ def compile_d2logp(
671650
jacobian : bool
672651
Whether to include jacobian terms in logprob graph. Defaults to True.
673652
"""
674-
return self.model.compile_fn(
653+
return self.compile_fn(
675654
self.d2logp(vars=vars, jacobian=jacobian, negate_output=negate_output),
676655
**compile_kwargs,
677656
)

tests/model/test_core.py

-16
Original file line numberDiff line numberDiff line change
@@ -1077,22 +1077,6 @@ def test_compile_fn():
10771077
np.testing.assert_allclose(result_compute, result_expect)
10781078

10791079

1080-
def test_model_pytensor_config():
1081-
assert pytensor.config.mode != "JAX"
1082-
with pytest.warns(FutureWarning, match="pytensor_config is deprecated"):
1083-
m = pm.Model(pytensor_config=dict(mode="JAX"))
1084-
with m:
1085-
assert pytensor.config.mode == "JAX"
1086-
assert pytensor.config.mode != "JAX"
1087-
1088-
1089-
def test_deprecated_model_property():
1090-
m = pm.Model()
1091-
with pytest.warns(FutureWarning, match="Model.model property is deprecated"):
1092-
m_property = m.model
1093-
assert m is m_property
1094-
1095-
10961080
def test_model_parent_set_programmatically():
10971081
with pm.Model() as model:
10981082
x = pm.Normal("x")

0 commit comments

Comments
 (0)