pymc-devs / pymc

Bayesian Modeling and Probabilistic Programming in Python
https://docs.pymc.io/
Other
8.47k stars 1.97k forks source link

Move CustomDist logic to dedicated module and docs section #7363

Closed markgreene74 closed 1 week ago

markgreene74 commented 2 weeks ago

@Hemant19870601 and I worked on this PR during the PyMC Hackathon at PyData London 2024.

Description

With this PR CustomDist is moved to a separate file (custom_distribution.py) along with related classes (CustomDistRV, CustomDistRV, CustomSymbolicDistRV, _CustomSymbolicDist) and helper functions (default_not_implemented, default_support_point).

The imports in distribution.py and __init__.py have been updated to reflect the changes.

DensityDist has been moved to the new file as well.

Note that in distribution.py the import of CustomSymbolicDistRV has been added close to where the class is used to avoid circular import. A noqa has been added on the same line to avoid a ruff error for the misplaced import (E402).

Similarly, the CustomDist tests have been moved to their own file (test_custom_distribution.py) and are passing.

Test results (before/after): file before (main branch) after
test_distribution.py 71 pass/14 ignored/85 total 33 pass/0 ignored/33 total
test_custom_distribution.py N/A 38 pass/14 ignored/52 total
71 pass/14 ignored/85 total 71 pass/14 ignored/85 total

Related Issue

Checklist

Type of change


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

welcome[bot] commented 2 weeks ago

Thank You Banner] :sparkling_heart: Thanks for opening this pull request! :sparkling_heart: 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.

markgreene74 commented 1 week ago

Hi @ricardoV94 thank you for all the comments :) I think this PR should be ready for review now, happy for me to change the status?

ricardoV94 commented 1 week ago

I rebased the PR on top of main to solve the conflicts with #7370

codecov[bot] commented 1 week ago

Codecov Report

Attention: Patch coverage is 94.59459% with 14 lines in your changes missing coverage. Please review.

Project coverage is 92.19%. Comparing base (e71d1cb) to head (9da36c3).

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/pymc-devs/pymc/pull/7363/graphs/tree.svg?width=650&height=150&src=pr&token=JFuXtOJ4Cb&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pymc-devs)](https://app.codecov.io/gh/pymc-devs/pymc/pull/7363?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pymc-devs) ```diff @@ Coverage Diff @@ ## main #7363 +/- ## ======================================= Coverage 92.18% 92.19% ======================================= Files 102 103 +1 Lines 17199 17214 +15 ======================================= + Hits 15855 15870 +15 Misses 1344 1344 ``` | [Files](https://app.codecov.io/gh/pymc-devs/pymc/pull/7363?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pymc-devs) | Coverage Δ | | |---|---|---| | [pymc/distributions/\_\_init\_\_.py](https://app.codecov.io/gh/pymc-devs/pymc/pull/7363?src=pr&el=tree&filepath=pymc%2Fdistributions%2F__init__.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pymc-devs#diff-cHltYy9kaXN0cmlidXRpb25zL19faW5pdF9fLnB5) | `100.00% <100.00%> (ø)` | | | [pymc/distributions/distribution.py](https://app.codecov.io/gh/pymc-devs/pymc/pull/7363?src=pr&el=tree&filepath=pymc%2Fdistributions%2Fdistribution.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pymc-devs#diff-cHltYy9kaXN0cmlidXRpb25zL2Rpc3RyaWJ1dGlvbi5weQ==) | `92.09% <100.00%> (-0.77%)` | :arrow_down: | | [pymc/distributions/truncated.py](https://app.codecov.io/gh/pymc-devs/pymc/pull/7363?src=pr&el=tree&filepath=pymc%2Fdistributions%2Ftruncated.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pymc-devs#diff-cHltYy9kaXN0cmlidXRpb25zL3RydW5jYXRlZC5weQ==) | `99.45% <100.00%> (+<0.01%)` | :arrow_up: | | [pymc/gp/util.py](https://app.codecov.io/gh/pymc-devs/pymc/pull/7363?src=pr&el=tree&filepath=pymc%2Fgp%2Futil.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pymc-devs#diff-cHltYy9ncC91dGlsLnB5) | `97.56% <100.00%> (-0.06%)` | :arrow_down: | | [pymc/model/core.py](https://app.codecov.io/gh/pymc-devs/pymc/pull/7363?src=pr&el=tree&filepath=pymc%2Fmodel%2Fcore.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pymc-devs#diff-cHltYy9tb2RlbC9jb3JlLnB5) | `91.75% <100.00%> (ø)` | | | [pymc/distributions/custom.py](https://app.codecov.io/gh/pymc-devs/pymc/pull/7363?src=pr&el=tree&filepath=pymc%2Fdistributions%2Fcustom.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pymc-devs#diff-cHltYy9kaXN0cmlidXRpb25zL2N1c3RvbS5weQ==) | `94.46% <94.46%> (ø)` | |
welcome[bot] commented 1 week ago

Congratulations Banner] Congrats on merging your first pull request! :tada: We here at PyMC are proud of you! :sparkling_heart: Thank you so much for your contribution :gift: