-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove several deprecated model properties and deprecate new ones #7033
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -496,7 +496,13 @@ | |
instance._parent = kwargs.get("model") | ||
else: | ||
instance._parent = cls.get_context(error_if_none=False) | ||
instance._pytensor_config = kwargs.get("pytensor_config", {}) | ||
pytensor_config = kwargs.get("pytensor_config", {}) | ||
if pytensor_config: | ||
warnings.warn( | ||
"pytensor_config is deprecated. Use pytensor.config or pytensor.config.change_flags context manager instead.", | ||
FutureWarning, | ||
) | ||
instance._pytensor_config = pytensor_config | ||
return instance | ||
|
||
@staticmethod | ||
|
@@ -559,6 +565,7 @@ | |
|
||
@property | ||
def model(self): | ||
warnings.warn("Model.model property is deprecated. Just use Model.", FutureWarning) | ||
return self | ||
|
||
@property | ||
|
@@ -629,7 +636,7 @@ | |
Whether to sum all logp terms or return elemwise logp for each variable. | ||
Defaults to True. | ||
""" | ||
return self.model.compile_fn(self.logp(vars=vars, jacobian=jacobian, sum=sum)) | ||
return self.compile_fn(self.logp(vars=vars, jacobian=jacobian, sum=sum)) | ||
|
||
def compile_dlogp( | ||
self, | ||
|
@@ -646,7 +653,7 @@ | |
jacobian: | ||
Whether to include jacobian terms in logprob graph. Defaults to True. | ||
""" | ||
return self.model.compile_fn(self.dlogp(vars=vars, jacobian=jacobian)) | ||
return self.compile_fn(self.dlogp(vars=vars, jacobian=jacobian)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should not it be root model instead? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the previous behavior. I don't know what should be happening with compiled function of nested models. I think nested models are a mistake. The functionality we want to provide with them (plating) is much more narrow than what nested models do. We should probably use something like |
||
|
||
def compile_d2logp( | ||
self, | ||
|
@@ -663,7 +670,7 @@ | |
jacobian: | ||
Whether to include jacobian terms in logprob graph. Defaults to True. | ||
""" | ||
return self.model.compile_fn(self.d2logp(vars=vars, jacobian=jacobian)) | ||
return self.compile_fn(self.d2logp(vars=vars, jacobian=jacobian)) | ||
|
||
def logp( | ||
self, | ||
|
@@ -886,27 +893,11 @@ | |
|
||
return vars + untransformed_vars + deterministics | ||
|
||
@property | ||
def disc_vars(self): | ||
warnings.warn( | ||
"Model.disc_vars has been deprecated. Use Model.discrete_value_vars instead.", | ||
FutureWarning, | ||
) | ||
return self.discrete_value_vars | ||
|
||
@property | ||
def discrete_value_vars(self): | ||
"""All the discrete value variables in the model""" | ||
return list(typefilter(self.value_vars, discrete_types)) | ||
|
||
@property | ||
def cont_vars(self): | ||
warnings.warn( | ||
"Model.cont_vars has been deprecated. Use Model.continuous_value_vars instead.", | ||
FutureWarning, | ||
) | ||
return self.continuous_value_vars | ||
|
||
@property | ||
def continuous_value_vars(self): | ||
"""All the continuous value variables in the model""" | ||
|
@@ -935,18 +926,6 @@ | |
""" | ||
return self.free_RVs + self.deterministics | ||
|
||
@property | ||
def RV_dims(self) -> Dict[str, Tuple[Union[str, None], ...]]: | ||
"""Tuples of dimension names for specific model variables. | ||
|
||
Entries in the tuples may be ``None``, if the RV dimension was not given a name. | ||
""" | ||
warnings.warn( | ||
"Model.RV_dims is deprecated. Use Model.named_vars_to_dims instead.", | ||
FutureWarning, | ||
) | ||
return self.named_vars_to_dims | ||
|
||
@property | ||
def coords(self) -> Dict[str, Union[Tuple, None]]: | ||
"""Coordinate values for model dimensions.""" | ||
|
@@ -1090,18 +1069,6 @@ | |
fn = make_initial_point_fn(model=self, return_transformed=True) | ||
return Point(fn(random_seed), model=self) | ||
|
||
@property | ||
def initial_values(self) -> Dict[TensorVariable, Optional[Union[np.ndarray, Variable, str]]]: | ||
"""Maps transformed variables to initial value placeholders. | ||
|
||
Keys are the random variables (as returned by e.g. ``pm.Uniform()``) and | ||
values are the numeric/symbolic initial values, strings denoting the strategy to get them, or None. | ||
""" | ||
warnings.warn( | ||
"Model.initial_values is deprecated. Use Model.rvs_to_initial_values instead." | ||
) | ||
return self.rvs_to_initial_values | ||
|
||
def set_initval(self, rv_var, initval): | ||
"""Sets an initial value (strategy) for a random variable.""" | ||
if initval is not None and not isinstance(initval, (Variable, str)): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤣