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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error in docstring example for MatrixNormal #7599

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

roesta07
Copy link

@roesta07 roesta07 commented Dec 1, 2024

…rrent version

Description

The compute_corr parameter in pm.LKJCholeskyCov is set to True by default, which causes the issue in latest pymc versions.
Also discussed here: https://discourse.pymc.io/t/matrixnormal-example-in-documentation-throws-an-error/16171

Related Issue

Checklist

Type of change

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

📚 Documentation preview 📚: https://pymc--7599.org.readthedocs.build/en/7599/

Copy link

welcome bot commented Dec 1, 2024

Thank You Banner]
💖 Thanks for opening this pull request! 💖 The PyMC community really appreciates your time and effort to contribute to the project. Please make sure you have read our Contributing Guidelines and filled in our pull request template to the best of your ability.

@roesta07
Copy link
Author

roesta07 commented Dec 3, 2024

Hi @cluhmann as per our conversation here. Also I am not sure why my pre-commit is failing because of different file which i have not touched.

Comment on lines 1830 to 1831
colchol_packed = pm.LKJCholeskyCov('colcholpacked', n=3, eta=2,compute_corr=False,
sd_dist=sd_dist)
Copy link
Member

Choose a reason for hiding this comment

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

A bit more succinct?

Suggested change
colchol_packed = pm.LKJCholeskyCov('colcholpacked', n=3, eta=2,compute_corr=False,
sd_dist=sd_dist)
colchol_packed, _, _ = pm.LKJCholeskyCov('colcholpacked', n=3, eta=2, sd_dist=sd_dist)

colchol_packed = pm.LKJCholeskyCov('colcholpacked', n=3, eta=2,
sd_dist=sd_dist)
colchol_packed = pm.LKJCholeskyCov('colcholpacked', n=3, eta=2,compute_corr=False,
sd_dist=sd_dist)
colchol = pm.expand_packed_triangular(3, colchol_packed)
# Setup left covariance matrix
scale = pm.LogNormal('scale', mu=np.log(true_scale), sigma=0.5)
rowcov = pt.diag([scale**(2*i) for i in range(m)])
vals = pm.MatrixNormal('vals', mu=mu, colchol=colchol, rowcov=rowcov,
Copy link
Member

@ricardoV94 ricardoV94 Dec 3, 2024

Choose a reason for hiding this comment

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

The suggestion can't be applied directyl, but this seems more clean

Suggested change
vals = pm.MatrixNormal('vals', mu=mu, colchol=colchol, rowcov=rowcov,
vals = pm.MatrixNormal('vals', mu=mu, colchol=colchol, rowcov=rowcov, observed=data)

@ricardoV94 ricardoV94 added the docs label Dec 3, 2024
@ricardoV94 ricardoV94 changed the title updated docstring for pm.MatrixNormal to ensure compatibility with cu… Fix error in docstring example for MatrixNormal Dec 3, 2024
@ricardoV94
Copy link
Member

@roesta07 you can ignore that pre-commit fail, it's indeed not related to your PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants