Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow opting out of model nesting by setting model=None #7352

Merged
merged 3 commits into from
Jun 17, 2024

Conversation

ricardoV94
Copy link
Member

@ricardoV94 ricardoV94 commented Jun 10, 2024

Description

This PR allows setting model=None to explicitly disable model nesting. This is needed for model transformations do, observe, clone, remove_value_transforms, freeze_rv_and_dims to be possible under a model context without side-effects on the original model.

I still think model nesting is an overkill, but a lot of code out there depends on it so I am not touching it.

I also updated the docstrings with more relevant (imo) examples. The previous example was broken as per #6715 and I am not sure we really want to incentivize people to subclass PyMC models. That certainly shouldn't be the focus of the docstrings?

Finally, removed deprecated functionality.

Related Issue

Checklist

Type of change

  • New feature / enhancement
  • Bug fix
  • Documentation
  • Maintenance
  • Other (please specify):

馃摎 Documentation preview 馃摎: https://pymc--7352.org.readthedocs.build/en/7352/

pymc/model/core.py Outdated Show resolved Hide resolved
pymc/model/core.py Outdated Show resolved Hide resolved
pymc/model/core.py Outdated Show resolved Hide resolved
Copy link
Member

@michaelosthege michaelosthege left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder how .to_graphviz looks for hierarchical models 馃

Please apply the docstring fixes that Oriol suggested 馃憤

pymc/model/core.py Outdated Show resolved Hide resolved
@ricardoV94
Copy link
Member Author

I wonder how .to_graphviz looks for hierarchical models 馃

Doesn't do anything different for the outer model. You can just call .to_graphviz on submodels and will only show the variables that belong to it IIRC

@ricardoV94 ricardoV94 merged commit 7d913ce into pymc-devs:main Jun 17, 2024
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs major Include in major changes release notes section model
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DOC: Provide a working example of inheriting from pymc.Model
3 participants