Skip to content

Commit bbfd69e

Browse files
committed
Deprecate Model.model property
1 parent 43ddea3 commit bbfd69e

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

pymc/model/core.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,7 @@ def __init__(
559559

560560
@property
561561
def model(self):
562+
warnings.warn("Model.model property is deprecated. Just use Model.", FutureWarning)
562563
return self
563564

564565
@property
@@ -629,7 +630,7 @@ def compile_logp(
629630
Whether to sum all logp terms or return elemwise logp for each variable.
630631
Defaults to True.
631632
"""
632-
return self.model.compile_fn(self.logp(vars=vars, jacobian=jacobian, sum=sum))
633+
return self.compile_fn(self.logp(vars=vars, jacobian=jacobian, sum=sum))
633634

634635
def compile_dlogp(
635636
self,
@@ -646,7 +647,7 @@ def compile_dlogp(
646647
jacobian:
647648
Whether to include jacobian terms in logprob graph. Defaults to True.
648649
"""
649-
return self.model.compile_fn(self.dlogp(vars=vars, jacobian=jacobian))
650+
return self.compile_fn(self.dlogp(vars=vars, jacobian=jacobian))
650651

651652
def compile_d2logp(
652653
self,
@@ -663,7 +664,7 @@ def compile_d2logp(
663664
jacobian:
664665
Whether to include jacobian terms in logprob graph. Defaults to True.
665666
"""
666-
return self.model.compile_fn(self.d2logp(vars=vars, jacobian=jacobian))
667+
return self.compile_fn(self.d2logp(vars=vars, jacobian=jacobian))
667668

668669
def logp(
669670
self,

tests/model/test_core.py

+7
Original file line numberDiff line numberDiff line change
@@ -1107,6 +1107,13 @@ def test_model_pytensor_config():
11071107
assert pytensor.config.mode != "JAX"
11081108

11091109

1110+
def test_deprecated_model_property():
1111+
m = pm.Model()
1112+
with pytest.warns(FutureWarning, match="Model.model property is deprecated"):
1113+
m_property = m.model
1114+
assert m is m_property
1115+
1116+
11101117
def test_model_parent_set_programmatically():
11111118
with pm.Model() as model:
11121119
x = pm.Normal("x")

0 commit comments

Comments
 (0)